tri*_*t77 0 javascript checkbox jquery this checked
我有很多表,当一个复选框被选中时 - 所有其他表应该清除.您可以在此表中检查任意数量的复选框,但只能一次检查一个表中的复选框.我该怎么做呢?我希望尽可能避免使用id,因为我有8个表.
$('input[type=checkbox]').on('click', function () {
});
Run Code Online (Sandbox Code Playgroud)
您可以 :
$(this).closest("table")
$("table").not($table)
... .prop("checked", false)
.这应该给出一些像这样的代码:
$('input[type=checkbox]').on('click', function () {
var $table = $(this).closest("table"); // Current table
$("table").not($table) // Other tables
.find("input[type=checkbox]:checked") // Checked input of these tables
.prop("checked", false); // Uncheck them
});
Run Code Online (Sandbox Code Playgroud)
看到这个小提琴:http://jsfiddle.net/69o3e5y4/2/
归档时间: |
|
查看次数: |
702 次 |
最近记录: |