开发者

Scroll to top after slideDown

开发者 https://www.devze.com 2023-03-16 18:26 出处:网络
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)

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

精彩评论

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

关注公众号