Why can't 80% of the code farmers can't do architects? >>> 
When I learned the "checkbox application", I found that the code is running on the FF. I don't think it is a browser. Later, I will change to IE, and I will find it online because it is because of it. Attr () should be replaced to prop () so that it can be displayed normally. The code is as follows:
Is your hobby?
<Input Type = "CheckBox" name = "items" value = "football" />
<input type = "checkbox" name = "items" value = "Basketball" />
<Input Type = "CheckBox" name = "items" value = "badminton" />
<Input Type = "Checkbox" name = "items" value = "Table Tennis" />
<Input Type = "Button" ID = "Checkedall" Value = "All Choice" />
<Input Type = "Button" ID = "CheckedRev" Value = "Reverse Selection" />
<Input Type = "Button" ID = "Checkedno" Value = "All Non-selected">
<Input Type = "Button" ID = "Send" value = "Submit" />
</form>
<script type="text/javascript">
$("#checkedAll").click(function(){
$('[name=items]:checkbox').prop('checked',true);
});//select all
$("#checkedNo").click(function(){
$('[name=items]:checkbox').prop('checked',false);
});//unselect all
$("#checkedRev").click(function(){
$('[name=items]:checkbox').each(function(){
this.checked=!this.checked;
})
}); // Reverse
// replace attr () with prop ();
$("#send").click(function(){
Var str = "You selected: \ r \ n";
$('[name=items]:checkbox:checked').each(function(){
str+=$(this).val()+"rn";
});
alert(str);
}); // Submit the output content
// checkbox application
</script>
Now why now?
In previous jQuery versions, use attr () to get the properties of the object, such as taking an ALT property of a picture, is $ ("# img"). Attr ('alt'); however, such as: disabled = "disabled" Different in different browsers are different; so from jQuery1.6, use PROP () to get standard properties: true / false; then $ "# checkbox"). Prop ('checked') will only return true / false without returning "disabled" or "";
Principles with prop ():
- Only the property name property will take effect immediately, such as SelectedIndex, Tagname, Nodename, Nodetype, OwnerDocument, defaultchecked, and defaultselected;
2. There is only the property of true / false, that is, the attribute is only the properties of the Boolean value;