我目前正在开发一个可编辑的x-editable表。我需要选择所有带有命名类 WITHIN 表行的节点并触发它们的.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结构下的表行中的给定类选择更好的元素吗?
答案 0 :(得分:1)
你错误地拼写了closest
。更改为closest('tr')
并改为find()
。
$('.myButton').click(function(){
// only this row of 'myeditable' should be selected
$(this).closest('tr')
.find('.myeditable').editable('submit', {....});
});
此外,editable()
不是jQuery函数。你在使用插件吗?