我不能让我的jQuery工作,我不知道我做错了什么

时间:2021-10-12 03:56:40

so I'm really new at all of this stuff and I'm a little stuck. I've been working on this project but for some reason I can't get my jQuery to load no matter what I do.

所以我对这些东西真的很新,我有点卡住了。我一直在研究这个项目,但出于某种原因,无论我做什么,我都无法加载我的jQuery。

here's my HTML

这是我的HTML

<head>
<meta charset="utf-8">
<title>Eerbivore</title>
    <link rel="stylesheet" href="gal.css">
<script src="jquery-2.1.3.min.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="gal.js"></script>

jQuery

$('#gallery').flickity({
    cellAlign: 'center',
    wrapAround: true
});

I'm using Brackets as my editor. Any help or anything thing I should add would be very helpful.

我正在使用Brackets作为我的编辑。任何帮助或任何我应该添加的东西都会非常有帮助。

2 个解决方案

#1


2  

I think the problem is here, you included more than one of jquery core library.

我认为问题出在这里,你包含了多个jquery核心库。

//<--- remove any of this
<script src="jquery-2.1.3.min.js"></script> 
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

And for this code, it is better if you put inside document.ready.(Ignore if already done this part)

对于这段代码,如果你放入document.ready中会更好。(如果你已经完成这部分,请忽略)

<script>
$(function(){
   $('#gallery').flickity({
     cellAlign: 'center',
     wrapAround: true
   });
});
</script>

#2


0  

as the others mentioned, only include one library of jquery, also worth mentioning that .flickity() is not native in jquery and the code for that should be included aswell.

正如其他人提到的那样,只包括一个jquery库,也值得一提的是.flickity()在jquery中不是本机的,并且应该包含其代码。

#1


2  

I think the problem is here, you included more than one of jquery core library.

我认为问题出在这里,你包含了多个jquery核心库。

//<--- remove any of this
<script src="jquery-2.1.3.min.js"></script> 
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

And for this code, it is better if you put inside document.ready.(Ignore if already done this part)

对于这段代码,如果你放入document.ready中会更好。(如果你已经完成这部分,请忽略)

<script>
$(function(){
   $('#gallery').flickity({
     cellAlign: 'center',
     wrapAround: true
   });
});
</script>

#2


0  

as the others mentioned, only include one library of jquery, also worth mentioning that .flickity() is not native in jquery and the code for that should be included aswell.

正如其他人提到的那样,只包括一个jquery库,也值得一提的是.flickity()在jquery中不是本机的,并且应该包含其代码。