RT, if you want to get the value inside the radio box, how to get it.
<script>window.onload = function () {//gets Getelementsbyname//var obj = Document.getelementsbyname by name (" Fruit ");//Get Getelementsbytagnamevar obj = document.getelementsbytagname (" Input ") via the tag; for (var i=0; i<obj.length; i + +) { if (obj[i].checked) { alert (obj[i].value);}} } </script><form><input type= "Radio" name = "Fruit" value= "apple" checked> Apple <input type= " Radio " name =" Fruit "value=" banana "> Banana <input type=" Radio " name =" Fruit "value=" pear "> Pear </form >
Knowledge Points:
1, get the element list by the name of the element
var obj = document.getelementsbyname ("fruit");
2, get the list of elements by the name of the tag
var obj = document.getelementsbytagname ("input");
3, whether to select
obj[i].checked;
4, the value in the Radio box
Obj[i].value;
JS gets the value in the Radio box