jQuery实现锚点scoll效果实例分析
2018-10-12 14:03
537 查看
本文实例讲述了jQuery实现锚点scoll效果的方法。分享给大家供大家参考。具体实现方法如下:
$('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;
var obj = document.documentElement;
if (jQuery.browser.safari)
obj = document.body
if (jQuery.browser.msie)
obj = 'html';
$(obj).animate({scrollTop: targetOffset}, 1000);
return false;
}
}
});
希望本文所述对大家的jQuery程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- jQuery实现div拖拽效果实例分析
- jQuery实现连续动画效果实例分析
- jQuery实现的超简单点赞效果实例分析
- jQuery实现div拖拽效果实例分析
- jQuery实现连续动画效果实例分析
- jQuery实现的超简单点赞效果实例分析
- jQuery实现的Div窗口震动效果实例
- jQuery实现仿淘宝带有指示条的图片转动切换效果完整实例
- 利用jQuery srollTop()函数实现类似锚点的定位效果-兼容chrome,firefox,IE,safari
- jquery实现的回旋滚动效果完整实例【附demo源码下载】
- ASP.NET jQuery 实例9 通过控件hyperlink实现返回顶部效果
- jquery简单实现点击弹出层效果实例
- Jquery实现列表(隔行换色,全选,鼠标滑过当前行)效果实例
- 用jquery中插件dialog实现弹框效果实例代码
- jQuery实现选项联动轮播效果【附实例】
- jQuery实现感应鼠标动画效果自动伸长的输入框实例
- jQuery实现的表头固定效果实例【附完整demo源码下载】
- jQuery实现的省市县三级联动菜单效果完整实例
- jQuery实现动画效果circle实例