Summary of Radio operations using jquery, jqueryradio
Radio is often used in development to achieve the user's choice. I have accumulated some methods to operate Radio using JQUERY in the project. Here I will share with you for reference.
1. Change the choice of radio to trigger some results.
Copy codeThe Code is as follows:
$ ("Input: radio [name = 'dialcheckresult']"). change (function () {// dial
Alert ("123 ");
});
2. Make all radio available on the page.
$ ("Input: radio"). attr ("disabled", false );
3. Disable all radio on the page.
$ ("Input: radio"). attr ("disabled", "disabled ");
4. Place a radio in the selected status.
$ ("Input: radio [name = 'dialcheckresult']"). eq (0). attr ("checked", true );
5. Make the "unselected" radio unavailable on the page.
$ ("Input: radio: not ([checked])"). attr ("disabled", "disabled ");
6. traverse the radio of the selected state. Except for one radio, the radio of other "selected" States is set to "unselected.
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. Make radio unavailable in all "unselected" states.
$ ("Input: radio: not ([checked])"). attr ("disabled", "disabled ");
8. Obtain the radio value of a specific NAME.
Var dialCheckResult = $ ("input: radio [name = 'dialcheckresult']: checked"). val ();
9. Place radio in the "unselected" status.
$ ('Input: radio: checked'). attr ('checked', false );
10. Place radio on the page in the "selected" or "unselected" status.
$ ("Input: radio"). attr ("checked", true );
$ ("Input: radio"). attr ("checked", false );
Set radio Selection in jquery
Your $ ("input [name = jizai]") selector will get two radio objects, both set and selected. Only the last one is selected, because it is a single choice.
If you want to write this, you can specify the index,
For example: $ ("input [name = jizai]: eq (0)"). attr ("checked", 'checked'); this is the first check.
In jquery, radio is selected or not.
$ ("# Rdo1"). attr ("checked", "checked ");
$ ("# Rdo1"). removeAttr ("checked ");
Another problem is hi me.
How can I use jquery to obtain the value of the selected radio?
If ($ ("input: radio [name =" xxx "]"). attr ("checked") {alert ("selected ");}