为了账号安全,请及时绑定邮箱和手机立即绑定

关于jq的插件研究

关于jq的插件研究

Cats萌萌 2018-09-13 10:10:54
$('a[href*="#"]:not([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) +']');      console.log( $('[name=' + this.hash.slice(1) +']'));      if (target.length) {        $('html, body').animate({          scrollTop: target.offset().top        }, 1000);        return false;      }    }  });这是个锚点滚动插件,看了下有一点不是很明白,$('[name=' + this.hash.slice(1) +']') 这个是应该怎么理解的?
查看完整描述

1 回答

?
犯罪嫌疑人X

TA贡献2080条经验 获得超4个赞

找锚点指向的元素 比如锚点是 
锚点的对象可能是<div id="top"></div>或者<div name="top"></div>

查看完整回答
反对 回复 2018-10-16
  • 1 回答
  • 0 关注
  • 623 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号