There are three ways for jquery to judge checked:

There are three ways jQuery determines checked:

.attr('checked'): // see version 1.6+ return: "checked" or "undefined" ; 1.5- return: true or false
.prop('checked'): //16+: true/false
.is( ':checked'): //all versions:true/false//don't forget the colon

Several ways to write jquery assignment checked:

All jquery versions can assign values ​​like this:

// $(“#cb1″).attr(“checked”,”checked”);
// $(“#cb1″).attr(“checked”,true);

jQuery1.6+: 4 assignments of prop:

// $(“#cb1″).prop(“checked”,true);//It’s very simple to say it
// $(“#cb1″).prop({checked:true}); //map key-value pair
// $("#cb1").prop("checked", function(){
return true; // function returns true or false
});

//Remember there is this: $("#cb1").prop("checked", "checked");

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326975354&siteId=291194637