Solve the jquery operation checkbox Firefox the second time cannot check the problem

Source: Internet
Author: User

In the work using jquery operation checkbox, select all, reverse the election, now the problem is the second time Firefox can not check the problem, there is a detailed answer below, interested friends can refer to the

Recently, using the jquery operation checkbox in your work, use the following method to select all, to reverse the selection: Copy code: 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, the click is checked, and then the 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 with $ ("* *"). attr ("Attrname"); the jquery version uses 1.9, which is a compatibility and stability issue. The jquery API clearly shows that 1.6+ jquery uses the prop, especially the checked properties of the checkbox, to copy the 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.