Home  >  Article  >  Web Front-end  >  JS 如何获取radio选中后的值及不选择取radio的值_javascript技巧

JS 如何获取radio选中后的值及不选择取radio的值_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:18:391459browse

以下是网上摘下的文章(未测试但很规范可以模仿)

复制代码 代码如下:




text
<script> <BR>var chk = 0; <BR>window.onload=function (){ <BR>var chkObjs = document.getElementsByName("radio"); <BR>for(var i=0;i<chkObjs.length;i++){ <BR>if(chkObjs[i].checked){ <BR>chk = i; <BR>break; <BR>} <BR>} <BR>} <BR>function check_radio(){ <BR>var chkObjs = document.getElementsByName("radio"); <BR>for(var i=0;i<chkObjs.length;i++){ <BR>if(chkObjs[i].checked){ <BR>if(chk == i){ <BR>alert("radio</script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn