Solve the problem that selecting all checkboxes is only valid once, and clicking later is invalid

allcheck is the select all checkbox, checkid is all other checkboxes. According to the Internet, jQuery1.6 and above all use prop, and the second time using attr will be invalid.

$("#allcheck").click(function(){

 

if($("input[name=allcheck]").prop("checked")){//Determine whether it is selected

$("input[name=allcheck]").prop("checked", true);//选中

$("input[name=checkid]").prop("checked", true);//选中

}else{

$("input[name=allcheck]").prop("checked", false);//取消选中

$("input[name=checkid]").prop("checked", false);//

}

 

})

Guess you like

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