jquery實現點擊按鈕滑動到指定位置

<body>javascript

<script type="text/javascript">
function click_scroll() {
var scroll_offset = $("#pos").offset(); //獲得pos這個div層的offset,包含兩個值,top和left
$("body,html").animate({
scrollTop:scroll_offset.top //讓body的scrollTop等於pos的top,就實現了滾動
},0);
}
</script>
<input type="button" value="點擊button跳轉" onclick="click_scroll();" />...
相關文章
相關標籤/搜索