Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.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
Javascript 导入后,jquery实际上是如何使用的?_Javascript_Jquery_Html_Css_Twitter Bootstrap - Fatal编程技术网

Javascript 导入后,jquery实际上是如何使用的?

Javascript 导入后,jquery实际上是如何使用的?,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,我正在从头开始做我的第一个项目,以前我使用过引导模板,并且做了很多更改,但是我总是遇到类的问题,而且变得非常复杂,所以我尝试使用引导css和js,以及jquery,因为我使用的所有模板似乎都导入了jquery 但随着我对javascript越来越熟悉,我已经制作了一些特定的.js文件,比如平滑滚动和不透明度衰减。但在我使用的所有模板中,这些东西似乎都很有效,只有jquery cdn和jquery简化,我如何将jquery中的内容(以及其中的实际内容?)应用到我的类中,或者实现平滑滚动和验证功能

我正在从头开始做我的第一个项目,以前我使用过引导模板,并且做了很多更改,但是我总是遇到类的问题,而且变得非常复杂,所以我尝试使用引导css和js,以及jquery,因为我使用的所有模板似乎都导入了jquery

但随着我对javascript越来越熟悉,我已经制作了一些特定的.js文件,比如平滑滚动和不透明度衰减。但在我使用的所有模板中,这些东西似乎都很有效,只有jquery cdn和jquery简化,我如何将jquery中的内容(以及其中的实际内容?)应用到我的类中,或者实现平滑滚动和验证功能

例如,为了平滑滚动,我必须制作自己的(实际上是从这里获得的)js,并以导航栏为目标,自己编辑一些变量

        $(document).ready(function(){
  // Add smooth scrolling to all links in navbar
  $(".navbar a.scroll,.navbar a.navbar-brand").on('click', function(event) {

  // Prevent default anchor click behavior
  event.preventDefault();

  // Store hash
  var hash = this.hash;

  // Using jQuery's animate() method to add smooth page scroll
  // The optional number (900) specifies the number of milliseconds it takes to scroll to the specified area
  $('html, body').animate({
    scrollTop: $(hash).offset().top - $('.navbar').height()
  }, 1600, 'easeInOutCubic', function(){

    // Add hash (#) to URL when done scrolling (default click behavior)
    window.location.hash = hash;
    });
  });
})

我需要在jquery js文件中也这样做吗


谢谢

“我需要在jquery js文件中也这样做吗”不,你很好不,我的意思是我需要更改变量以便jquery生效吗?听起来你需要这样做: