我正在一個包含Table插件的網站上工作。插件獲取由<script>
標記導入並使用javascript執行。除了使用Bootstrap外,bootstrap.min.js文件也是重要的。下面是它的外觀:右closeing的<body>
標記之前腳本標記不關閉
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#table_id').DataTable();
});
</script>
所有這些代碼放置。如果我將文件上傳到我的網站空間並訪問該頁面,則不會執行任何腳本。如果我看一看在Chrome的源代碼,所有我看到的是<script>
標籤不正常關閉:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"/>
<script charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js" type="text/javascript"/>
<script type="text/javascript">
$(document).ready(function() {
$('#table_id').DataTable();
});
</script>
我已經試過放在不同勢地方的腳本代碼,但每次也有同樣的問題。我也試過this的答案,但是評論甚至沒有顯示在源代碼中。
有沒有什麼合適的方法可以解決這個問題?
(UPDATE:完整代碼):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
<xsl:template match="/">
<html>
<head>
<title>Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- Latest compiled and minified Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css"/>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12">
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#table_id').DataTable();
});
</script>
</body>
</html>
任何登錄控制檯? –
當我將其粘貼在小提琴中時,它工作正常。你測試了哪些瀏覽器? – kalsowerus
這可能來自您尚未發佈的內容。可能是你的腳本標籤之前的東西。 – Dash