我無法嘗試對動態創建的html表格進行排序。我用玉/帕格創建它。我正在嘗試使用這裏找到的sorttable.js腳本http://www.kryogenix.org/code/browser/sorttable/。我對html/javascript仍然很陌生。所以,如果有一些明顯的原因,爲什麼它不工作可以請人指出?使用sorttable.js無法排序html表格
下面是一些從模板
<html>
<head>
<script src="/path/to/sorttable.js"></script>
<style>
th.clickable:hover
{
color:green
}
th, td
{
padding:5px;
}
th.clickable
{
cursor: pointer;
}
</style>
</head>
<body>
<script>
var newTableObject = document.getElementById(tbl)
sorttable.makeSortable(newTableObject)
</script>
<table class="sortable" id="tbl">
<tr>
<th class="clickable">id</th>
<th class="clickable">value</th>
</tr>
<tr>
<td>100</td>
<td>100</td>
</tr>
<tr>
<td>200</td>
<td>200</td>
</tr>
</table>
</body>
</html>
的目標是有它所以當我點擊它按該列排序表頭生成的HTML代碼。
或者您可以嘗試將您的腳本塊移動到您的聲明表下,但這不是最好的,最明顯的解決方案。 – jusopi
嘗試兩個,仍然沒有運氣:\ – user2770808
適合我(即被稱爲onload和表不被定義)http://codepen.io/jusopi/pen/pbKymd – jusopi