Summary _jquery using jquery operation Radio Method

Source: Internet
Author: User

In the development of radio often used to achieve the user's choice, I have accumulated some of the project using jquery to operate the radio method, here to share, for the needs of friends for reference.

1, change the choice of radio, trigger some effect

Copy Code code as follows:

$ ("Input:radio[name= ' Dialcheckresult ']"). Change (function () {//Dial
Alert ("123");
});

2. Make all the radio in the page available.

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

3, so that all the radio on the page is not available.

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

4, let a radio placed in the selected state.

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

5, let the page "unchecked" status of the radio is not available.

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

6, traverse the selected state of the radio, in addition to a certain radio, the other "checked" status of the radio set is "not selected" state.

Copy Code code as follows:

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

7, so that all "unchecked" status of the radio is not available.

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

8, get a selected radio of the specific name of the value.

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

9, let all the "checked" status of the radio placed in the "unchecked" state.

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

10, let the page radio are placed in the "checked" status or "unchecked" status.

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

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

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.