This article mainly introduces the jquery to determine whether the radio button radio selected method, the example analysis of the loading page when the radio button ID and click button to get radio button ID two methods, very simple and practical, the need for friends can refer to the next
This example describes how jquery determines whether a radio button radio is selected. Share to everyone for your reference. Specific as follows:
The HTML code is as follows:
<input type= "Radio" id= "D1" name= "RA" value= "a" checked= "checked"/><input type= "Radio" id= "D2" Name= "RA" value = "B"/><input type= "Radio" id= "D3" Name= "Ra" value= "C"/>
1. Get ID when loading the page
$ ("input[type= ' Radio ')"). each (function () { var id= $ (this). attr ("id"); if ($ ("#" +id). attr ("checked") = = "Checked") { var fs=$ ("#" +id). Val (); }); var S1 = $ (". Aa:checked"). Val (); . AA is Classvar s2 = $ ("Input[name= ' ra ']:checked"). Val ();
2. Get the ID when you click on the button
$ (function () { $ ("input[type= ' Radio ')"). Click (function () { var id= $ (this). attr ("id"); alert (ID); });
It is hoped that this article will be helpful to everyone's jquery program design.
Originating From: http://www.jb51.net/article/65504.htm
jquery Determines whether the radio button radio is selected