jquery checkbox repeated calls to attr (' checked ', true/false) only take effect for the first time

Source: Internet
Author: User

/* *   * Select All * *    function  checkall () {       $ (true);   }      /** *   all not   selected *    /function  uncheckall () {       $ (false);   

Problem Description:

The initial status check box does not have a full selection,

Click the Select All button to call the Checkall method,

A full selection is achieved,

Then click the Uncheck All button,

To achieve a complete no-election,

Then click the Select All button again,

The result is a full selection of wood,

Then repeatedly click on the wood to have any reaction.

Workaround:

The use of the prop method instead of the attr method is solved.

/* *  *  Select All * *   function  checkall () {      $ (true);  }

Reference Address: http://blog.csdn.net/tunzao/article/details/17225173

jquery checkbox repeated calls to attr (' checked ', true/false) only take effect for the first time

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.