2017-08-31 81 views
-1

我有下面的html代码,我已经包含了几个js文件。只有jquery文件加载,而其他2个文件不加载。有人可以指出我哪里出错了。当我通过检查元素检查网络选项卡时,发现其他js文件的请求根本没有打中。 enter image description here为什么有些js文件不能在html中加载?

<html> 
<head> 
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css"> 
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.1.1/css/responsive.dataTables.min.css"> 

<style> 
div.container { max-width: 1200px } 
</style> 

</head> 
<body> 

<table id="example" class="display compact nowrap" cellspacing="0" width="100%"> 
     <thead> 
      <tr> 
       <th>First name</th> 
       <th>Last name</th> 
       <th>Position</th> 
       <th>Office</th> 
       <th>Age</th> 
       <th>Start date</th> 
       <th>Salary</th> 
       <th>Extn.</th> 
       <th>E-mail</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
       <td>Tiger</td> 
       <td>Nixon</td> 
       <td>System Architect</td> 
       <td>Edinburgh</td> 
       <td>61</td> 
       <td>2011/04/25</td> 
       <td>$320,800</td> 
       <td>5421</td> 
       <td>[email protected]</td> 
      </tr> 

      <tr> 
       <td>Rhona</td> 
       <td>Davidson</td> 
       <td>Integration Specialist</td> 
       <td>Tokyo</td> 
       <td>55</td> 
       <td>2010/10/14</td> 
       <td>$327,900</td> 
       <td>6200</td> 
       <td>[email protected]</td> 
      </tr> 
      <tr> 
       <td>Colleen</td> 
       <td>Hurst</td> 
       <td>Javascript Developer</td> 
       <td>San Francisco</td> 
       <td>39</td> 
       <td>2009/09/15</td> 
       <td>$205,500</td> 
       <td>2360</td> 
       <td>[email protected]</td> 
      </tr> 
     </tbody> 
    </table> 


</body> 
<script src="https://code.jquery.com/jquery-1.12.4.js"/> 
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"/> 
<script src="https://cdn.datatables.net/responsive/2.1.1/js/dataTables.responsive.min.js"/> 
<script> 
$(document).ready(function() { 
    var table = $('#example').DataTable({ 
     responsive: true 
    }); 
}); 
</script> 
</html> 

回答

4

<script>不是自闭标签。请尝试以下操作:

<script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script> 
<script src="https://cdn.datatables.net/responsive/2.1.1/js/dataTables.responsive.min.js"></script> 
+2

仅仅因为现代浏览器可以很好地处理它们,并不意味着您应该使用不良行为进行编码。它最终会爬上你。 –

3

<script>标签可能有一些问题与自闭的形式。试试这个:

<script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script> 
<script src="https://cdn.datatables.net/responsive/2.1.1/js/dataTables.responsive.min.js"></script> 
相关问题