javascript - .slideToggle auto scroll down to reveal content -


I am using .slideToggle to open a link when the user clicks on a link:

  & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ("BTN-Slide"). Click (function () {$ ("# panel") Slide Toggle ("Slow"); $ (this) .toggleClass (" Active "); return false;});}); & Lt; / Script & gt;  

Toggle is taller than the height of the divisor with the content of the divas (# panels) so that the scolberbers are visible. I want to scroll vertically to reveal the new vertical scroll when the vertical scrollbar is toggled when I think that I can do this with .scrollTop to do this, but I'm not sure the same How to know about doing this in time ... any thoughts?

EDIT: There is a consensus that this is the best way to achieve what I have described:

   

This panel slides but the scroll down effect is not working.

I have done something like this before:

  $ (" .btn-slide "). Click (function (if ($ (this) .hasClass ("active") $ $ (this) .removeClass ("active"); $ ("# panel") SlideUp ("slow"); } $ (This) .addClass ("active"); $ ("#"). SlideDown ("slow") var destination = $ ("# container") .offet (). Top + $ ("# ("ScrollTop: Destination", "slow"); // or // $ ("# container"). ({ScrollTop: Destination}, "Slow" , "Fx_name_here");} event.preventDefault ();});  

HTML:

  & lt; A href = "#" class = "btn-slide" & gt; Fire panel & lt; / A & gt; & Lt; Div id = "container" & gt; & Lt; Div id = "panel" & gt; Sdfsdfsdfs & lt; / Div & gt; & Lt; / Div & gt; 

Edit:

If you download, you can add different effects to the sliding, which can add the Fx name code (line in response Commented out)

Better code is less code but has the same effect.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -