javascript - Show div and move to top of page -



javascript - Show div and move to top of page -

this question has reply here:

animate scrolltop not working in firefox 10 answers

at moment i'm showing/hiding div box when click button:

$j('#button').click(function () { $j('#box').slidetoggle(); homecoming false; });

but move box top of page when it's shown , hide when clicked again. code below doesn't seem work:

$j('#button').click(function () { $j('#box').slidetoggle(); $j('html').animate({ scrolltop: $j('#box').offset().top },400); homecoming false; });

am doing wrong?

you have set animate statement box, too.

i created demo you, hope understood want :-)

demo toggle hidden div , move top of window

$('#button').click(function() { $('#box').slidetoggle(); $('#box').animate({ top: 0 }, 400); homecoming false; });

http://jsfiddle.net/b11kmnkp/

javascript jquery

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -