Summary of radio method using jquery operation

Source: Internet
Author: User

Using radio to achieve the user's choice effect, in the project accumulated some use jquery to operate the radio method, here with you to share the next

In the development often use radio to achieve the user's choice effect, I accumulated in the project some use jquery to operate the radio method, here to share, for the needs of friends to learn from.

1, change the choice of radio, trigger some effects

Copy CodeThe code is as follows:
$ ("Input:radio[name= ' Dialcheckresult ')". Change (function () {//Dial
Alert ("123");
});


2. Make all radio available in the page.

$ ("Input:radio"). attr ("disabled", false);

3. Make all radio in the page unavailable.

$ ("Input:radio"). attr ("Disabled", "disabled");

4. Let a radio in the selected state.

$ ("Input:radio[name= ' Dialcheckresult ']"). EQ (0). attr ("Checked", true);

5. Make the radio in the "Unchecked" State of the page unavailable.

$ ("Input:radio:not ([checked])"). attr ("Disabled", "disabled");

6, traversing the selected state of the radio, in addition to one radio, the other "selected" state radio setting is "unchecked" state.

Copy CodeThe code is as follows:
$ (' input:radio:checked '). each (function (i,val) {
if (val.name! = "Dialcheckresult") {
$ ("Input:radio[name= '" "+val.name+" ']:checked "). attr (' checked ', false);
}
});


7. Radio is not available for all "unchecked" states.

$ ("Input:radio:not ([checked])"). attr ("Disabled", "disabled");

8. Get the value of the radio of a particular name that is selected.

var dialcheckresult=$ ("Input:radio[name= ' Dialcheckresult ']:checked"). Val ();

9. Leave the radio of all "checked" states in the unchecked state.

$ (' input:radio:checked '). attr (' checked ', false);

10. Let the radio in the page be in the "checked" state or "unchecked" state.

$ ("Input:radio"). attr ("Checked", true);

$ ("Input:radio"). attr ("checked", false);

Summary of radio method using jquery operation

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.