如何在jquery中选择表行中的所有命名类
我目前正在处理一个引导x-可编辑表。我需要选择表行中具有给定命名类的所有节点,并触发它们的.editable()。这是我的jquery选择器代码如何在jquery中选择表行中的所有命名类,jquery,twitter-bootstrap,jquery-selectors,Jquery,Twitter Bootstrap,Jquery Selectors,我目前正在处理一个引导x-可编辑表。我需要选择表行中具有给定命名类的所有节点,并触发它们的.editable()。这是我的jquery选择器代码 <table class="table table-bordered"> <thead> ............. </thead> <tr> <td><a class="myeditable editable-user" data-type=
<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>
在我的Html结构下,有谁能找到更好的解决方案,通过表行中给定的类来选择元素吗?您拼写的
最近的错了。更改为最近('tr')
,改为执行find()
$('.myButton').click(function(){
// only this row of 'myeditable' should be selected
$(this).closest('tr')
.find('.myeditable').editable('submit', {....});
});
另外,editable()
不是jQuery函数。你在使用插件吗?壁橱应该是一个方法中最接近的和兄弟的<代码>$(this).closest('td').sides().children('.myeditable')
它应该可以工作。或者只需执行$(this).closest('tr')。find('myeditable')
谢谢PSL。这是个打字错误。它是一种魅力。
$('.myButton').click(function(){
// only this row of 'myeditable' should be selected
$(this).closest('tr')
.find('.myeditable').editable('submit', {....});
});