js 获得radio的值

var tmp = document.getElementsByName("foodtype");
for(var i=0; i<tmp.length; ++i)
    if(tmp.item(i).checked){
      alert(tmp.item(i).getAttribute("value"));
   }
原文地址:https://www.cnblogs.com/hujunzheng/p/4167897.html