2012-05-30 139 views

回答

1

我假設它是被假定的菜單項被激活,如果這樣加this到您的鏈接:

<a href="#" onClick="Animate2id('#c1', this);return false">Content 1</a> 

做:

<script type="text/javascript"> 
    function Animate2id(id2Animate, elm){ 
    $(elm).addClass('active').siblings().removeClass('active'); 
    var animSpeed=1500; //animation speed 
    var easeType="easeInOutExpo"; //easing type 
    $("html, body").stop().animate({scrollTop: $(id2Animate).offset().top}, animSpeed, easeType); 
    } 
</script> 

FIDDLE

這隻有在點擊菜單時才能使用!