problem: JQ is used at work uery operation of the Multi-box (checkbox) Knowledge, the previous records and notes to find out the direct use, but the problem arises, deselect, select the specified multi-box again, with the browser (F12) is added checked property, but the page display is not selected (no tick) , here's a summary of how to solve the problem.
Here's a solution (using jquery version 2.1.3):
1. Static page checkbox.html (Note: You must add the Select attribute to the check tag)
<! DOCTYPE html>2, JS file Multi-Select, deselect and reverse (checkbox.js)function SelectAll () {$ ("input[name= ' CheckBox1 ')"). each (function () { $ (this). Prop ("checked", true);}); function Fanxuan () {$ ("input[name= ' CheckBox1 ')"). each (function () {if ($ (). Prop ("checked") = = True) {alert ($ (this) . attr ("checked")); $ (this). Prop ("checked", false);} Else{alert ($ (this). attr ("checked")); $ (this). Prop ("checked", true);});} function Cancelselect () {$ ("input[name= ' CheckBox1 ')"). each (function () { $ (this). Prop ("checked", false);});
Here to use the time Prop property, the following analysis of the reasons, in order to avoid the re-build wheel, we can go to the following two articles to look at:Refer to the differences between attr and prop in article 1:jquery
Reference article 2:jquery the difference between attr method and prop method
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
jquery operation checkbox (multi box)