欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery 跳到頂部和底部動畫2句代碼簡單實現(xiàn)

 更新時間:2013年07月18日 17:43:45   作者:  
使用2句代碼簡單實現(xiàn)jquery動畫的跳到頂部和底部;當點擊頂部按鈕的時候,執(zhí)行方法,scrollTop屬性獲取選中標簽距滾動條的距離,具體的實現(xiàn)如下,感興趣的朋友可以參考下
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script type="text/javascript" src=jquery-1.8.0.js></script>
<script>
$(document).ready(function () {
//當點擊頂部按鈕的時候,執(zhí)行方法,scrollTop屬性獲取選中標簽距滾動條的距離。
$('#top').click(function () {
$('html').animate(
{ scrollTop: '0px' }, 1000
);
});
//當點擊底部標簽時候,執(zhí)行方法,其中offset()獲取匹配元素在當前視口的相對偏移,返回的是一個對象,有兩個屬性top,left
//animate,的第二個屬性當然我們也可以設(shè)置'slow','normal'或'fast'
$('#foot').click(function () {
$('html').animate(
{scrollTop:$('span').offset().top},1000
);
});
});
</script>
</head>
<body>
<br /> <br /> <br /> <br /> <br />
<a href="#" id="foot">底部</a>
<br /> <br /> <br /> <br /> <br />
<br /> <br /> <br /> <br /> <br />

<a href="#" id="top">頂部</a>
<br /> <br /> <br /> <br /> <br />
<span></span>
</body>
</html>

相關(guān)文章

最新評論