我目前正在开发一个引导 x 可编辑表。我需要在表行中选择具有给定命名类的所有节点并触发它们的 .editable() 。这是我的 jquery 选择器代码。
<table class="table table-bordered">
<thead>
.............
</thead>
<tr>
<td><a class="myeditable editable-user" data-type="select" href="#">user...</a></td>
<td><a class="myeditable editable-date" data-type="date" href="#">date...</a></td>
<td><a class="myeditable editable-user" data-type="text" href="#">description..</a></td>
<td><span class="actions"><a class="myButton" href="#">submit changes</a></span></td>
</tr>
<tr>
.......... the same contents as above
</tr>
</table>
我的脚本应该是这样的:
$('.myButton').click(function(){
// only this row of 'myeditable' should be selected
$(this).closet('td')
.siblings.children('.myeditable').editable('submit', {....});
});
谁能有更好的解决方案来通过我的 Html 结构下的表行中的给定类来选择元素?