Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
这个JQuery块到底在做什么?_Jquery - Fatal编程技术网

这个JQuery块到底在做什么?

这个JQuery块到底在做什么?,jquery,Jquery,有人能逐行解释一下吗 $(function() { $('.js-nav a, .js-connect').click(function(e) { e.preventDefault(); $('body, html').animate({ scrollTop: $($.attr(this, 'href')).offset().top }, 750); })); }); 点击.js nav a链接,页面将滚动到$.attr(这个“href')的位置,我猜这是链接目标。

有人能逐行解释一下吗

     $(function() {
 $('.js-nav a, .js-connect').click(function(e) {
     e.preventDefault();
 $('body, html').animate({
  scrollTop: $($.attr(this, 'href')).offset().top
}, 750);
}));
});

点击
.js nav a
链接,页面将滚动到
$.attr(这个“href')
的位置,我猜这是链接目标。

浏览jQuery api中的特定方法……这样做会给你一个非常好的主意。在提出问题之前,应该先做这样的基础研究