日期:2014-05-16 浏览次数:20403 次
<html> <head> <title>初始化单选</title> <script> function initradio(rName,rValue){ var rObj = document.getElementsByName(rName); for(var i = 0;i < rObj.length;i++){ if(rObj[i].value == rValue){ rObj[i].checked = 'checked'; } } } </script> </head> <body> <form action="#"> 黑<input type="radio" name="tRadio" value="1"> 色<input type="radio" name="tRadio" value="2"> 头<input type="radio" name="tRadio" value="3"> 发<input type="radio" name="tRadio" value="4"> </form> <script> initradio('tRadio',3); </script> </body> </html>