内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
我对编码很陌生,我正试图创建一个表,其中每个列都可以被过滤。我从JSFiddle资源中拼凑了这段代码,它在他们的网站上运行得很好,但我无法让它在其他地方工作。它引用了一个外部js,我认为这就是它可能出错的地方。
这是原始资源的链接:http: //jsfiddle.net/eCqG3/3229/
这是我的版本:
var table2_Props = { col_0: "select", col_1: "select", col_2: "select", col_3: "select", display_all_text: " [ Show all ] ", sort_select: true }; var tf2 = setFilterGrid("table2", table2_Props);
table.table2 { background-color: #ffffff; color: #4e4e4e; cursor: pointer; padding: 10px; width: 100%; border: none; text-align: left;
<script src="http://tablefilter.free.fr/TableFilter/tablefilter_all_min.js"></script> <p>Add a drop-down filter, define its first option, sort it and remove a filter</p> <table id="table2" cellpadding="0" cellspacing="0"> <tr> <th>Account Type</th> <th>Form Name</th> <th>Form Type</th> <th>Account Name</th> <th>Special Instructions</th> </tr> </table>
非常感谢你的帮助 - 我真的被卡住了!
你的脚本在DOM准备好之前就被执行了。
把你的剧本放在结尾之前</body>
标记之前或使用此代码:
document.addEventListener("DOMContentLoaded", function(event) { // your js code });