In the work, use jquery to operate checkbox for full selection and invert selection. The problem is that Firefox cannot check the problem for the second time. A detailed answer is provided below, if you are interested, refer to using jquery to operate the checkbox at work recently. Use the following methods to select all and invert:
The Code is as follows:
Var ischecked = allCheckObj. is (': checked ');
Ischecked? ChecksObj. attr ('checked', true): checksObj. attr ('checked', false );
There was no problem with ie during debugging. Considering compatibility, I tried firefox and encountered a problem. Therefore, we did the following experiments:
The check box is bound with a click event. click Select once, click unselect, and so on. This function is okay in ie, but it is okay in the previous two tests in firefox. It can be properly displayed and canceled, but when it is selected again, the checkbox value of the attribute of the check box is changed to "checked". No problem, but the check box does not display the selected status. It is strange that the attribute value is changed but not checked. The code is modified but cannot be correctly displayed. After a long time, you cannot find the cause.
Positive solution: it turned out to be a jQuery version after idol guidance. My operation properties use
$ ("**"). Attr ("attrName"); jQuery uses 1.9, which is a problem of compatibility and stability.
JQuery API clearly states that more than 1.6 of jQuery should use prop, especially the checked attribute judgment of checkBox, that is
The Code is as follows:
$ ("Input [type = 'checkbox']"). prop ("checked ");
$ ("Input [type = 'checkbox']"). prop ("disabled", false );
$ ("Input [type = 'checkbox']"). prop ("checked", true );
In use, change attr to prop to solve the problem.
Have you encountered this strange problem? Try it.