The examples in this article summarize the jquery method of operating checkbox. Share it with everyone for your reference. The specific analysis is as follows:
Three ways for jquery to determine checked:
$("input").attr("checked"); //Version 1.6 Return: "checked" or "undefined", 1.5-return: true or false
$("input").prop("checked"); //16 :true/false
$("input").is(":checked"); //All versions: true/false
Several ways to write jquery assignment checked:
All jquery versions can be assigned like this:
$("input").attr("checked","checked");
$("input").attr("checked",true);
jquery1.6: 4 types of assignment of prop:
$("input").prop("checked",true) ;
$("input").prop({checked:true}); //map key-value pairs
$("input").prop("checked",function(){
Return true;//The function returns true or false
});
$("input").prop("checked","checked");
I hope this article will be helpful to everyone’s jQuery programming.