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 answersat 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
Post a Comment