Jquery 如果条件选中所有复选框
仅选择属性设置为Jquery 如果条件选中所有复选框,jquery,Jquery,仅选择属性设置为checked=“checked”的项目,但它会选择所有项目 <input class="chxbx" type="checkbox" checked="checked"> <input class="chxbx" type="checkbox"> <input class="chxbx" type="checkbox"> 您没有正确使用。每个 应该是: $(".chxbx").each(function(){ if($(this
checked=“checked”
的项目,但它会选择所有项目
<input class="chxbx" type="checkbox" checked="checked">
<input class="chxbx" type="checkbox">
<input class="chxbx" type="checkbox">
您没有正确使用
。每个
应该是:
$(".chxbx").each(function(){
if($(this).is(":checked")){
// this should select only the the input tag with
//checked="checked" but it selects all checkboxes
}
});
或者:
$(".chxbx:checked").each(function(){
// this should select only the the input tag with
//checked="checked" but it selects all checkboxes
});
您没有正确使用。每个
应该是:
$(".chxbx").each(function(){
if($(this).is(":checked")){
// this should select only the the input tag with
//checked="checked" but it selects all checkboxes
}
});
或者:
$(".chxbx:checked").each(function(){
// this should select only the the input tag with
//checked="checked" but it selects all checkboxes
});
问题是什么?我认为您需要$(“.chxbx:checked”)
如果条件选中所有复选框,请参阅Hi Satpal。在html中,只检查第一个输入标记,而jquery如果条件需要显示只有第一个标记已检查,问题是什么?我认为您需要$(“.chxbx:checked”)
如果条件选中所有复选框,请参阅Hi Satpal。在html中,只选中第一个输入标记,而jquery if条件需要显示只有第一个标记已选中