我希望能够通过单击取消选中一个单选按钮.
因此,如果未选中单选按钮,我想检查它,如果选中它,我想取消选中它.
这不起作用:
$('input[type=radio]:checked').click(function(){
$(this).attr('checked', false);
});
Run Code Online (Sandbox Code Playgroud)
我现在无法检查单选按钮.
我有以下内容:
for (var i = 0; i < children.length; i++){
if(hasClass(children[i], "lbExclude")){
children[i].parentNode.removeChild(children[i]);
}
};
Run Code Online (Sandbox Code Playgroud)
我希望它能够遍历所有孩子的孩子等(不仅仅是顶层).我找到了这条线,似乎这样做:
for(var m = n.firstChild; m != null; m = m.nextSibling) {
Run Code Online (Sandbox Code Playgroud)
但是,如果我进行转换,我不清楚我如何引用当前的孩子?我不再需要澄清孩子的指数位置.有什么建议?
谢谢!
更新:
根据答案的建议,我现在正在使用以下内容.这是正确/最有效的方式吗?
function removeTest(child) {
if (hasClass(child, "lbExclude")) {
child.parentNode.removeChild(child);
}
}
function allDescendants(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
allDescendants(child);
removeTest(child);
}
}
var children = temp.childNodes;
for (var i = 0; i < children.length; i++) {
allDescendants(children[i]);
};
Run Code Online (Sandbox Code Playgroud) 我的表格中的每一行都有一些复选框.每个复选框都有,name='myName'因为我想在每行中只选择一个复选框.但是我错过了一些东西,因为我能够检查所有这些:

但我想要那个结果:

我在这里想念的是什么?