我正在尝试对由 JSP 填充的表使用 datatable jquery 插件。我在 $(document).ready(function()) 中添加了数据表初始化,但由于某种原因该插件无法执行搜索或分页。我的代码片段是
<table class="data-table" id="test">
<thead>
<tr>
<th>value1</th>
<th>value2</th>
<th>value3</th>
<th>value4</th>
</tr>
</thead>
<tbody>
<tr>
<td class="class1"><%= value.valueOne() %></td>
<td class="class2"><%= value.valueTwo() %></td>
<td class="class3"><%= value.valueThree() %></td>
<td class="class4"><%= value.valueFour() %></td>
</tr>
<%
}
%>
</tbody>
</table>
<script>
$(document).ready(function() {
alert("HELLO");
$('#test').dataTable();
});
</script>
任何其他遇到此问题的人,我们将不胜感激。
最佳答案
$(document).ready() 函数在加载整个页面时执行,无论您在代码中的何处编写它。 更多信息:http://learn.jquery.com/using-jquery-core/document-ready/
关于javascript - $(document).ready(function()) 仅在jsp加载后执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19626259/