我有一个下面的函数,我只想在同一个中的复选框被选中时触发它。
$(".add_menu_item_table").live('click', function() {
if ($('input.checkbox_check').attr(':checked')); {
// I want this to trigger.
}
});
<table id="table-data">
<tbody>
<tr>
<td><input type="checkbox" class="checkbox_check"></td>
<td><input type="button" class="add_menu_item_table" value="Add"></td>
</tr>
<tr>
<td><input type="checkbox" class="checkbox_check"></td>
<td><input type="button" class="add_menu_item_table" value="Add"></td>
</tr>
</tbody>
</table>
$('input.checkbox_check').checked
返回true
,否则返回false
。 - Don Cheadlechecked
属性。我想你是指$('input.checkbox_check')[0].checked
。 - Paulchecked: function(){return this.is(:checked)}
就行了。 - Rager