This article mainly introduces jquery's method of determining whether or not the single-choice button radio is selected. The instance analyzes the two methods of obtaining the single-choice button ID when loading the page and obtaining the single-choice button ID when clicking the button, it is very simple and practical. If you need it, you can refer to the examples in this article to describe 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:
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.