从href向下滚动到div

时间:2013-12-17 09:12:15

标签: jquery css

我想用jQuery从href向下滚动到特定的div,我的代码是:

<ul class="menu2">
    <li><a href="#whoweare">About</a></li>
    <li><a href="#services">Services</a></li>
</ul>
<div id="whoweare"></div>
<div id=services "></div>

谢谢

1 个答案:

答案 0 :(得分:1)

$(".YourClass").click(function () {
    $('html,body').animate({ scrollTop: $(this.hash).offset().top }, 500);
});