In a fit of rage, I added an isCheck to the checkbox, without using the damn checked attribute... Everything was OK... The code is as follows: Copy code The code is as follows: Fix the status switching and dynamic value problem of checkbox <br>* {margin:0; padding:0;} <br>ul li { float:left; list-style:none; margin-left:20px;} <br>< /style> <br></head> <br><body> <br><form name="journal" id="journal" action="#" method="post"> <br>< ;input name="cate_ids" value="" type="hidden"> <br><ul> <br><li><input checked="checked" isCheck="true" class="ckbox" value="1" name="cate_id" type="checkbox">Gourmet 1</li> <br><li><input class="ckbox" value="2" name="cate_id" type= "checkbox">Food 2</li> <br><li><input class="ckbox" value="3" name="cate_id" type="checkbox">Food 3</li> <br><li><input checked="checked" isCheck="true" class="ckbox" value="4" name="cate_id" type="checkbox">Food 4</li> <br> <li><input checked="checked" isCheck="true" class="ckbox" checked="checked" value="5" name="cate_id" type="checkbox">Food 5</li> <br></ul> <br><div class="btn"> <input value="Confirm" name="sbtn" onclick="getValues()" type="button"> <br></form> <br><br><script> <br>//Fix the problem of checkbox state switching and dynamic value acquisition<br>//Add an isCheck attribute to the checkbox to replace the checked attribute. Compatibility <br>$(".ckbox").click(function(){ <br>if($(this).attr("isCheck") == "true") { <br>$(this). removeAttr("isCheck") <br>} else { <br>$(this).attr("isCheck", "true"); <br>} <br>}) <br>function getValues() <br> { <br>var list=""; <br>$(".ckbox").each(function(){ <br>if($(this).attr("isCheck") == "true"){ <br>list = $(this).val() ","; <br>} <br>}) <br>alert(list); <br>} <br></script> <br>< ;/body> <br></html> <br> </div>