开发者

Make all <li>s, when clicked, scroll to a single anchor?

开发者 https://www.devze.com 2023-03-19 13:48 出处:网络
I have around 30 li nodes. When each one is clicked, I would like the browser to gently scroll to the div sliderbox. (I don\'t wnt to use anchor tags)

I have around 30 li nodes. When each one is clicked, I would like the browser to gently scroll to the div sliderbox. (I don't wnt to use anchor tags)

So, something like this:

$("#boxcont li").click(function(event){
   // (Make stuff happen here)
)开发者_开发百科};

How can I do this?


check ths out

$("#boxcont li").click(function(event){
$('html,body').animate({ scrollTop: $('#sliderbox').offset().top }, { duration: 'slow', easing: 'swing'});
});


you can try this: document.location=document.location + "#anchorName"; add <a name="anchorName"></a> in the location you wish to scroll to

0

精彩评论

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