jquery回到页面顶端
html代码:
<h1 id="anchor">页面标题</h1><div id="container">页面内容</div><p><a href="#anchor" name="code">#container{ height: 1000px; line-height: 1000px; text-align: center; font-family: Arial; border: 1px solid #EEEEEE;}.topLink{ float:right; padding:10px; color: #CCC;}
$(document).ready(function() {$("a.topLink").click(function() {$("html, body").animate({scrollTop: $($(this).attr("href")).offset().top + "px"}, {duration: 500,easing: "swing"});return false;});});