[英]Include external html table data
好的,所以我有一個HTML jquery tablesorter網頁。 與其將所有“ td”標簽嵌入同一文件中,我想從一個單獨的文件中加載它們。 原因是數據非常大,並且是模塊化所必需的。 到目前為止,這是我正在嘗試的...。
<div id="demo"><table class="tablesorter">
<script src="https://www.w3schools.com/lib/w3.js"> w3.includeHTML();</script>
<br>
<!-- Table Head -->
<thead>
<tr>
<th>Sensor</th> <!-- disable dragtable on this column -->
<th class="drag-enable">c1</th>
<th class="drag-enable">c2</th>
<th class="drag-enable">c3</th>
<th class="drag-enable">c4</th>
<th class="drag-enable">c5</th>
<th class="drag-enable">c6</th>
</tr>
</thead>
<!-- Table Footer -->
<tfoot>
<tr><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th><th>c6</th><th>c7</th></tr>
</tfoot>
<!-- Table Content -->
<tbody w3-include-html="C:\Users\user\Desktop\new_test\tabledata.html">
</tbody>
</table>
</div>
據我了解,您尚未正確初始化w3.includeHTML()
方法。
問題是您需要初始化w3.includeHTML();
在您的html代碼末尾
試試下面的代碼:
<!DOCTYPE html>
<html>
<script src="https://www.w3schools.com/lib/w3.js"></script>
<body>
<div id="demo">
<table class="tablesorter">
<br>
<!-- Table Head -->
<thead>
<tr>
<th>Sensor</th> <!-- disable dragtable on this column -->
<th class="drag-enable">c1</th>
<th class="drag-enable">c2</th>
<th class="drag-enable">c3</th>
<th class="drag-enable">c4</th>
<th class="drag-enable">c5</th>
<th class="drag-enable">c6</th>
</tr>
</thead>
<!-- Table Footer -->
<tfoot>
<tr><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th><th>c6</th><th>c7</th></tr>
</tfoot>
<!-- Table Content -->
<tbody w3-include-html="C:\Users\user\Desktop\new_test\tabledata.html">
</tbody>
</table>
</div>
<script>
w3.includeHTML();
</script>
</body>
</html>
試試這個,讓我知道,以防您遇到問題。
我讓它像這樣工作:
<table id="table" class="tablesorter">
<script src="columndata.js"></script>
</table>
然后在.js文件中,我只有一個變量和document.write。 非常簡單且有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.