Jquery determines whether the single-choice button radio is selected, jqueryradio
This example describes how jquery checks whether the single-choice button radio is selected. Share it with you for your reference. The details are 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 the 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 = 'a']: checked "). val ();
2. Obtain the id when you click the button.
$ (Function () {$ ("input [type = 'Radio ']"). click (function () {var id = $ (this ). attr ("id"); alert (id );});});
I hope this article will help you with jQuery programming.