我在MySQL中有一个包含主键列的表.
让我们说:
ID | Value
1 | One
2 | Two
6 | Three
8 | Four
9 | Five
Run Code Online (Sandbox Code Playgroud)
我如何得到它:
ID | Value
1 | One
2 | Two
3 | Three
4 | Four
5 | Five
Run Code Online (Sandbox Code Playgroud)
没有其他表格.只是一个.我只是想让ID成为一个合适的系列.
有什么建议?? 一个查询也许.. :)
我已将点击处理程序附加到表格行元素,我需要一些帮助来从点击处理程序中排除带有类子菜单的元素。
我尝试使用 jQuery :not选择器成功排除整个td元素,但这不是我想要的。
下面的代码需要jQuery、Bootstrap和FontAwesome才能工作。请参考上面的 JsFiddle 链接。
HTML
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Details</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>123</td>
<td>Name 1
<div class="pull-right sub-menu">
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><i class="fa fa-chevron-down"></i>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li><a href="#">Edit</a></li>
<li><a href="#">Delete</a></li>
<li><a href="#">Block</a></li>
</ul>
</div>
</div>
</td>
<td>New User</td>
<td>Pending</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
Javascript
$(function() {
$('table tr').on('click', function() {
alert('Clicked');
}); …Run Code Online (Sandbox Code Playgroud)