This article introduces how to obtain the Radio element value in jQuery. If you need it, you can refer to it and find that the JavaScript code you have written has an error running in FireFox. The reason is very depressing, when obtaining the value of a Radio element, only undefind is required.
Google, most of them are the same as what I use
The Code is as follows:
Var value = $ ("input [name = 'radio1'] [type = 'radio'] [checked]"). val ();
This statement is successfully tested in IE and Safari (3.2), but cannot be selected in FireFox or Chrome.
Read the manual carefully and find the list of "form object attributes. Is there a special method for determining the attributes of a form object? Change the code
The Code is as follows:
Var value = $ ("input [name = 'radio1'] [type = 'radio']: checked"). val ();
All tests passed in IE, FireFox, Chrome, and Safari (3.2.
By the way, I tested the select element. The method in the manual is similar to the one I often use. The correct value can be obtained in the preceding browsers.
The Code is as follows:
Var value1 = $ ("select"). val (); var value2 = $ ("select option: selected"). val ();
I tested it in jQuery 1.32. You can try it.