jquery如何实现锚点链接之间的平滑滚动

时间:2013-12-02    点击:112   
复制代码 代码如下:

$('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) {
var targetOffset = $target.offset().top;
$('html,body').animate({
scrollTop: targetOffset
},
500);
return false;
}
}
});
探讨jQuery的ajax使用场景(c#)
解析Javascript小括号“()”的多义性
解析Javascript中中括号“[]”的多义性
jquery将一个表单序列化为一个对象的方法
jQuery获得内容和属性方法及示例
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved