jquery Let’s summarize the problem of determining whether the check box is selected and how to select it.
Let’s get to the point, or when the page has the following set of check boxes:
Apple
Orange
Banana
Grape
Then use Jquery to get name=fruit The method of setting the value of a set of checkboxes is as follows:
var checkVal='';
$("input[name='fruit']:checkbox").each(function( ){
if($(this).attr('checked')){
checkVal+=$(this).val()+',';
}
})
Determine whether the check box of the name=fruit group has a selected option:
var flag=false;
$( "input[name='fruit']:checkbox").each(function(){
if($(this).attr('checked')){
flag=true ;
}
})
if(flag){
alert('has been selected');
}else {
alert('No option is selected');
}
The above is how jquery determines whether a check box is selected. I hope It will be helpful for everyone’s learning. You can also use js to obtain it. Please refer to "JS Determine Whether the Checkbox Is Selected Example"
The above is the detailed content of Summary of jquery's example of determining whether a check box is selected. For more information, please follow other related articles on the PHP Chinese website!