首页 > 其他 > 详细

锚点跳转滑动效果

时间:2016-11-08 16:40:17      阅读:169      评论:0      收藏:0      [点我收藏+]
$(‘a[href*="#"],area[href*="#"]‘).click(function() {
console.log(1);
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
},
1000);
return false;
}
}
});
//且网页没有后缀

锚点跳转滑动效果

原文:http://www.cnblogs.com/huangqiming/p/6043325.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!