Js得到radiobuttonlist选中值,设置默认值

JS 代码

var vRbtid=document.getElementById("rbtid");
      
//得到所有radio
      var vRbtidList= vRbtid.getElementsByTagName("INPUT");
      
for(var i = 0;i<vRbtidList.length;i++)
      {
        
if(vRbtidList[i].checked)
        {
           
var text =vRbtid.cells[i].innerText;
           
var value=vRbtidList[i].value;
           alert(
"选中项的text值为"+text+",value值为"+value);
        }
      }

 vRbtidList[0].checked = true; 设置默认值

   vRbtidList[1].checked = false;

原文地址:https://www.cnblogs.com/xuxin-1989/p/3716248.html