Find out which type of form element the radio button is:
var x = document.getElementById("myRadio").type;
Click the radio button to find out which type of form element it is.
<!DOCTYPE html> <html> <body> <input type="radio" onclick="myFunction()" id="myRadio"> <p id="demo"></p> <script> function myFunction() {/*from w w w .j ava 2s . co m*/ var x = document.getElementById("myRadio").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The type property returns which type of form element a radio button is.
For a radio button object, this property will always return "radio".