I have made small jquery collapse/expand script
http://jsfiddle.net/goldie/QFL49/ (please don't pay attenton to html/css code because I did'n made it)
How can I make expanded div to scro开发者_运维百科ll to the top of the page? Thank you for help.
I have found it
.slideDown(200, function() {
$('html, body').delay('200').animate({
scrollTop: $(this).offset().top - 111
}, 200);
});
Found this in the end, works fine:
.slideDown(200, function() {
$('html, body').delay('200').animate({
scrollTop: $(this).offset().top
}, 200); }); } });
you could use .scrollTop or if you want it animated, do .animate({"top": "0px"},1000) for example
There is also the jQuery scrollTo plugin, http://plugins.jquery.com/project/ScrollTo
精彩评论