开发者

Scroll to top after slideDown

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜