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

用jquery實(shí)現(xiàn)動(dòng)畫跳到頂部和底部(這個(gè)比較簡單)

 更新時(shí)間:2014年09月01日 09:39:25   投稿:whsnow  
用jquery實(shí)現(xiàn)動(dòng)畫的跳到頂部和底部,當(dāng)點(diǎn)擊頂部按鈕的時(shí)候,執(zhí)行方法,scrollTop屬性獲取選中標(biāo)簽距滾動(dòng)條的距離

當(dāng)點(diǎn)擊頂部按鈕的時(shí)候,執(zhí)行方法,scrollTop屬性獲取選中標(biāo)簽距滾動(dòng)條的距離,當(dāng)點(diǎn)擊底部標(biāo)簽時(shí)候,執(zhí)行方法,其中offset()獲取匹配元素在當(dāng)前視口的相對偏移

<!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 () {
//當(dāng)點(diǎn)擊頂部按鈕的時(shí)候,執(zhí)行方法,scrollTop屬性獲取選中標(biāo)簽距滾動(dòng)條的距離。
$('#top').click(function () {
$('html').animate(
{ scrollTop: '0px' }, 1000
);
});
//當(dāng)點(diǎn)擊底部標(biāo)簽時(shí)候,執(zhí)行方法,其中offset()獲取匹配元素在當(dāng)前視口的相對偏移,返回的是一個(gè)對象,有兩個(gè)屬性top,left
//animate,的第二個(gè)屬性當(dāng)然我們也可以設(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)文章

最新評(píng)論