The jQuery operation check box (checkbox) attr checked does not work, jqueryattr

Source: Internet
Author: User

The jQuery operation check box (checkbox) attr checked does not work, jqueryattr
JQuery changes the checkbox status, which is invalid.

 

$ (This). attr ("checked", false). checkboxradio ("refresh"); // It should be written in this way. It's missing $ this stuff ~~~ Confused with js

The jQuery operation check box (checkbox) attr checked does not work.

 

 

The jQuery function is used this day. To achieve a simple check box, select all or none dynamically. The test results show that attr ('checked', 'checked'); and attr ('checked ', true); either the first call is successful, and the second call is unresponsive and does not work at all. Why?

This helps the customer's house to search for jQuery checkbox operations on the Internet. The articles on dynamic selection all write the following code:

$ ('Input [type = checkbox] '). attr ('checked', 'checked'); // select all and set the attribute $ ('input [type = checkbox] '). attr ('checked', true); // select all, set the attribute, in the form of a true Boolean value $ ('input [type = checkbox] '). attr ('checked', false); // do not select, Boolean format $ ('input [type = checkbox] '). removeAttr ('checked', 'checked'); // if this parameter is not selected, the property is deleted.

 

However, the test results show that it is difficult to perform multiple tests. You can select a full selection, call a reverse selection, and then call a full selection.

Is it the reason for removeAttr? Or the new jQuery 1.9.1 version has been used by the 'helper home. (Or do I need to use native javascript code to do this ?)

These are not the reasons, and they should be useless. It is impossible for such a simple framework to be implemented (and do not doubt the browser's problem)

Final Solution

Go to the official website, search for 'checkbox', find an article, and check carefully. A similar operation is

 

$ ('Obj '). attr ('checked', true );

$ ('Obj '). prop ('checked', true );

$ ('Obj '). attr ('checked', false );

$ ('Obj '). prop ('checked', false );

Okay, keep your eyes open. That's right. It's okay to use the prop method to operate everything.

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.