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