2 回答

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超4個贊
<a href="#" onClick="click_scroll('here1');">滾動到here1</a>
<a href="#" onClick="click_scroll('here2');">滾動到here2</a>
<script type="text/javascript">
function click_scroll(a) {
var e = $('#'+a);
var scroll_offset = e.offset();
$("body,html").animate({scrollTop:scroll_offset.top},300);
}
</script>
<div style="height:500px" ></div>
<div id="here1">點(diǎn)擊后滾動到here1</div>
<div id="here2">點(diǎn)擊后滾動到here2</div>

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個贊
無論你怎么來實(shí)現(xiàn)多個滾動效果,你body的滾動條只有一個,真正的滾動到的位置是最后一個滾動的。前面的會依次被后面的給覆蓋掉。
就好比你定義變量var a=1;你需要吧a賦值成a=2,然后再賦值成a=3;那最后a的值就是3......
添加回答
舉報(bào)