Jquery函数没有正确链接?为什么我的<script>部分可以运行?

时间:2018-04-08 00:47:51

标签: javascript jquery

一直在尝试创建一个简单的“小队建设者”,基本上只是创建一个列表,因为单击了不同的按钮。我注意到Jquery没有工作,尽管它已经链接到了该部分。我甚至无法访问基本动画。这里发生了什么?:

&#xA;&#xA;
 &lt;!DOCTYPE html&gt;&#xA;&lt; link rel =“stylesheet”href =“https:/ /maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css“integrity =”sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va + PmSTsz / K68vbdEjh4u“crossorigin =”anonymous“&gt;&#xA;&#xA;&lt; head&gt ;&#XA;&#XA; &lt; title&gt; Squad Builder&lt; / title&gt;&#xA; &lt; meta charset =“utf-8”/&gt;&#xA; &lt; meta http-equiv =“Content-type”content =“text / html; charset = utf-8”/&gt;&#xA; &lt; meta name =“viewport”content =“width = device-width,initial-scale = 1”/&gt;&#xA; &lt; script src =“// code.jquery.com/jquery-1.11.3.min.js"></script>

</head>
&# xA;&lt; script type =“text / javascript”&gt; &#XA;&#XA; $(document).ready(function(){&#xA;&#xA; $(“button”)。addClass(“animated bounce”);&#xA;&#xA;});&#xA;& #xA;&lt; / script&gt;&#xA;&#xA;&lt; style type =“text / css”&gt;&#xA;&#xA; #player-box {&#xA;&#xA; background-color:red;&#xA;身高:500px;&#xA;宽度:130px;&#xA; }&#XA;&#XA; #quad-box {&#xA;&#xA; background-color:red;&#xA;身高:500px;&#xA;宽度:500px;&#xA; margin-left:10px;&#xA; }&#xA;&lt; / style&gt;&#xA;&#xA;&lt; body&gt;&#xA;&#xA;&lt; div class =“row container-fluid”&gt;&#xA; &lt; div id =“player-box”class =“col-md-6”&gt;&#xA;&#xA; &lt; ul id =“player-list”&gt;&#xA;&#xA; &lt; li&gt;&lt; button class =“player-btn btn”&gt; Player1&lt; / button&gt;&lt; / li&gt;&#xA; &LT; / UL&GT;&#XA; &LT; / DIV&GT;&#XA;&#XA; &lt; div id =“squad-box”class =“col-md-6”&gt;&#xA;&#xA; &lt; ul id =“squad-list”&gt;&#xA;&#xA; &LT; / UL&GT;&#XA; &LT; / DIV&GT;&#XA;&LT; / DIV&GT;&#XA;&#XA;&#XA;&LT; / BODY&GT;&#XA;  
&#XA;

1 个答案:

答案 0 :(得分:1)

您的代码没问题,可能只缺少 animate.css 资产:

troubleshooting

&#13;
&#13;
$(document).ready(function() {
  $("button").addClass("animated bounce");
});
&#13;
#player-box {
  background-color: red;
  height: 500px;
  width: 130px;
}

#squad-box {
  background-color: red;
  height: 500px;
  width: 500px;
  margin-left: 10px;
}
&#13;
<link href="https://daneden.github.io/animate.css/animate.min.css" rel="stylesheet" />
<!DOCTYPE html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>

<div class="row container-fluid">
  <div id="player-box" class="col-md-6">
    <ul id="player-list">
      <li><button class="player-btn btn">Player1</button></li>
    </ul>
  </div>
  <div id="squad-box" class="col-md-6">
    <ul id="squad-list">
    </ul>
  </div>
</div>
&#13;
&#13;
&#13;