我在使用tablesorter jquery插件时遇到了一些麻烦。 问题是,我有一种观点,即当单击一个提交按钮时,根据表单的搜索,将加载一个包含来自数据库的信息的表。该表仅在单击“搜索”按钮时显示,并不总是显示相同的信息。我试图使用tablesorter jquery插件,但它似乎并没有工作。我打电话:对页面加载后提交按钮时出现的表格进行排序
<script src="/js/jquery-1.12.1.min.js" type="text/javascript"></script>
<script src="js/jquery.tablesorter.min.js"></script>
<head>
<script>
function sort_my_table(){
$('my_table').tablesorter();
}
</script>
</head>
,然后在下面的表格。
当我按下此按钮时,表格显示在页面底部,按钮提交表单,您可以在其中输入所需的信息,然后使用此信息进行搜索,然后表格显示结果搜索:
<input type="submit" class="btn btn-primary" value="search" name="send">
我的表看起来像这样:
<thead>
<tr>
<th style="text-align:center">Code</th>
<th style="text-align:center">Name</th>
<th style="text-align:center">Description</th>
</tr>
</thead>
<?php foreach ($elements as $element) { ?>
<tbody>
<tr>
<td><?php echo $element->fabr?></td>
<?php if (count($element->place) > 0) { ?>
<td>
<?php foreach ($element->place as $pl) { ?>
<?php echo $pl['name'] ?><br>
<?php } ?>
</td>
<td>
<?php foreach ($element->place as $pl) { ?>
<?php echo $pl['number'] ?><br>
<?php } ?>
</td>
<?php } else { ?>
<td></td>
<td></td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
我真的不知道如何使用它,或者如何使它发挥作用。
确保'my_table'是一个“正确的”css选择器......它应该使用类名称(句点;'.my_table')或id(hash;'#my_table')来定位表格。 – Mottie