JQuery cannot set the checkbox check box selection cause resolution, jquerycheckbox

Source: Internet
Author: User

JQuery cannot set the checkbox check box selection cause resolution, jquerycheckbox

Why does jQuery fail to set the checkbox check box:
Many coders may encounter this strange situation, that is, they use jQuery to set the checkbox to an invalid status, even though the Code has no errors, the following describes why this problem occurs and how to solve it. We hope to help our friends who need it.
Let's first look at a code example:

 

<! DOCTYPE html> 

 

In the above Code, when you select all for the first time and then cancel all the selections, then click "select all" again, this will not work, and there will be no problem before jQuery1.9, there is no problem in IE8 and IE8 browsers. To solve this problem, modify the Code as follows:

<! DOCTYPE html> 

You only need to change the attr () function to the prop () function. The main reason is the difference between element property and attribute.
Related reading:
1. For details about property and attribute attributes, refer to the introduction section of js property and attribute attributes.
2. For browser compatibility issues, see section 1 about Attribue attribute compatibility of js.

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 13046.

For more information, see: http://www.softwhy.com/jquery/

 

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.