<inputtype="checkbox"name="chk"value="1"val="level 1">Level 1<inputtype="checkbox"name="chk"value="2"checked="checked"val="2">Level 2<inputtype="checkbox"name="chk"value="3"val="3">Level 3
1) Set level 1 and level 3 to select
2) Get the selected value and display it separately with ','
Change the default state:
$(":checkbox").attr("checked", function() { if ($(this).is(":checked")) { return false; } else { return true; } });Traversal value:
$(":checkbox").click(function() {var arrayValue = new Array();$(":checkbox").each(function(){if ($(this).is(":checked")) {arrayValue.push($(this).val()); } }); arrayValue.join(","); alert(arrayValue); });The above implementation code for changing the default selected status and value of checkbox is all the content I have shared with you. I hope you can give you a reference and I hope you can support Wulin.com more.