Dar*_*ius 1 jquery dom-traversal
I have a script that is supposed to select all descendant input checkbox, when the ancestor checkbox is selected.
见这里:http : //jsfiddle.net/zJPfR/
选中顶层复选框时,将选中下面的所有复选框。如果您取消选中该复选框,则会删除这些检查。但是,如果您尝试第二次执行此操作,则不起作用。
如果我不正确地处理这个问题,请告诉我。
大流士
$('.poSelect').click(function() {
var expandBox = $(this).parents('.pohelpTbl').next('.expandBox');
var receipts = expandBox.find('input[type="checkbox"]');
if ($(this).is(':checked')) {
var status = true;
} else {
var status = false;
}
$(receipts).each(function (i) {
var cb = $(this);
cb.attr("checked",status);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1208 次 |
| 最近记录: |