JQuery sets all checkbox options (different from jQuery versions) and checkboxjquery

Source: Internet
Author: User

JQuery sets all checkbox options (different from jQuery versions) and checkboxjquery

JQuery sets all checkbox options. There are various articles on the Internet, but why is it ineffective when we use their code?

If your code has no errors at all, do not worry about the correctness of your code first. Maybe it's just that the jQuery version you use is different.

Many versions of jQuery will make some improvements to some small functions, such as the checkbox selection.

The line version jquery1.9.1 of jQuery's changes to the checkbox.

Before jquery1.9.1, select all of the following options:

$ ('# Checkbox'). attr ('checked', true) $ (' # checkbox'). attr ('checked', false)

After jquery1.9.1, select all of them as follows:

$ ('# Checkbox'). prop ('checked', true) $ (' # checkbox'). prop ('checked', false)

Determine whether or not to select. After my experiment:

It can only be used before jquery1.9.1.

$ ("Input [name = 'chk _ all']"). attr ('checked ');

It can be used later.

$ ("Input [name = 'chk _ all']"). is ('checked'); and $ ("input [name = 'chk _ all']"). prop ('checked ');

If any error occurs, correct 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.