<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<metahttp-equiv="X-UA-Compatible"content="IE=EmulateIE7"/>
<title>jquery实现锚点跳转平滑滚动效果 - www.osxue.com</title>
<scripttype="text/
javascript"src="jquery.min.js"></script>
<scripttype="text/JavaScript">
$(document).ready(function(){
$('a[href*=#]').click(function(){
if(location.pathname.replace(/^//,'')==this.pathname.replace(/^//,'')&&location.
hostname==this.hostname){
var$target=$(this.hash);
$target=$target.length&&$target||$('[name='+this.hash.slice(1)+']');
if($target.length){
vartargetOffset=$target.offset().top;
$('html,body').animate({
scrollTop:targetOffset
},
1000);
returnfalse;
}
}
});
});
</script>
</head>
<body>
<p>0</p>
<pid="top">top</p>
<p><ahref="#bottom">bottom</a></p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<p>0</p>
<pid="bottom">bottom</p>
<p><ahref="#top">top</a></p>
<p>0</p>
</body>
</html>
$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');