In jquery, a checkbox repeatedly calls attr (' checked ', true/false) only the first-time solution that takes effect _jquery

Source: Internet
Author: User

This example describes the solution that the checkbox in jquery repeatedly calls attr (' checked ', true/false) only for the first time. Share to everyone for your reference, specific as follows:

First look at the following code:

/**
 * All select
 /function Checkall () {
   $ ("input[name=ids]"). attr ("Checked", true);
 }
 /**
 * Do not select
 /
 function Uncheckall () {
   $ ("input[name=ids]"). attr ("checked", false);
 }

Problem Description:

The initial state checkbox is not fully selected, click the Select button to call the Checkall method, the implementation of the full selection, and then click the Full selection button to achieve a full choice, and then click the Full Selection button again, the result is a full selection of wood, and then repeatedly click on the wood has any reaction.

Workaround:

Google's:

Instead of the attr method using the Prop method,

/**
 * All select
/function Checkall () {
  $ ("input[name=ids]"). Prop ("checked", true);
}

Solve the problem!

More interested readers of jquery-related content can view the site: "jquery form Operation Tips", "jquery switching effects and techniques summary", "jquery drag-and-drop effects and techniques summary", "JQuery Extended Skills Summary", " jquery Common Classic Effects Summary "jquery animation and special effects usage Summary", "jquery selector usage Summary" and "jquery common Plug-ins and Usage summary"

I hope this article will help you with the jquery program design.

Related Article

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.