How to take input of radio button with only using javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to take input of radio button with only using javascript?

not a form validation, without a form tag. can anybody help me in this?

25th Jan 2018, 7:48 PM
Vivek Tiwari
1 Answer
+ 1
var radio = document.getElementsByClassName("radio"); Return the value of radio button radio.value if radio is checked radio.checked For multiple radio buttons for(var a = 0; a < radio.length; a++) { if(radio[a].checked) { console.log(radio[a].value); return; } }
25th Jan 2018, 9:00 PM
Toni Isotalo
Toni Isotalo - avatar