today, with the jquery learning form, this section of the chapter, once again encountered the full selection of the form, can not be a second full-time situation. There is still no reason to see the test repeatedly. Later on the Internet to find that the original is jQuery1.6 after the version used is prop. Using attr will not be implemented more than once, because attr does not record the current checkbox's selected state.
This chapter of the form makes me feel a little hard, in short, good work!
Here is the code description:
<! DOCTYPE html> $(function(){ //using attr /*$ ("#CheckedAll"). Click (function () {if (this.checked) {$ (' [Name=items]:checkbox ')]. attr (' Checke d ', false); } else {$ (' [Name=items]:checkbox '). attr (' checked ', true); } });*/ //using prop$ ("#CheckedAll"). Click (function(){ if( This. Checked) { $(' [Name=items]:checkbox '). Prop (' checked '),false); } Else { $(' [Name=items]:checkbox '). Prop (' checked '),true); } });*/ }); </script>What's your favorite sport? <br> <input type= "checkbox" name= "items" value= "soccer" >Football<input type= "checkbox" name= "items" value= "basketball" >Basketball<input type= "checkbox" name= "Items" value= "Badminton" >Badminton<input type= "checkbox" name= "Items" value= "Table tennis" > table tennis <br> <input type= "button" id= "Checkedall" value= " Select All "> <input type=" button "id=" Checkedno "value=" Select All "> <input type=" button "id=" Checkedrev "Valu e= "Reverse Selection" > <input type= "button" id= "send" value= "submit" > </form></body>For the distinction between attribute and property, refer to: HTTP://WWW.TUICOOL.COM/ARTICLES/3UUQRR6
About the differences between prop and attr in the jquery form selection.