Recently, using the jquery operation checkbox in your work, use the following method to select all, to reverse the selection:
Copy Code code as follows:
var ischecked=allcheckobj.is (': checked ');
Ischecked?checksobj.attr (' checked ', true): checksobj.attr (' checked ', false);
Debugging in IE no problem, considering compatibility, try Firefox, encountered a problem. As a result, the following experiments were done:
The check box binds the Click event, selects once, and then clicks Uncheck, and so on. This function in IE no problem, but in Firefox test, the first two times are no problem, you can display the check and cancel, but when you go to select, check box property checkbox value to "checked", no problem, but check box does not show the selected state, Obviously the attribute value changed, but did not show tick, too strange. Code modification but not get the right display status, tangled up for a long time, can not find the reason.
Positive solution: Later by the idol direction, the original jquery version of the problem. I manipulate attributes using the
$ ("* *"). attr ("Attrname"); the jquery version uses 1.9, which is a compatibility and stability issue.
The jquery API clearly shows that 1.6+ jquery is judged by the attributes of the prop, especially the checked of the checkbox, i.e.
Copy Code code as follows:
$ ("input[type= ' checkbox ']"). Prop ("checked");
$ ("input[type= ' checkbox ']"). Prop ("disabled", false);
$ ("input[type= ' checkbox ']"). Prop ("checked", true);
In use is to change the attr to prop, the problem is solved.
Have you met this strange question? Just try it.