html radio 是否选中的判断

论坛 期权论坛 脚本     
匿名技术用户   2021-1-6 08:48   46   0
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Platform</title>
</head>
<script type="text/javascript">

 function genderShow(){
  if(document.getElementById("male").checked)
  {
   alert(document.getElementById("male").value);
  }
  if(document.getElementById("female").checked){
   alert(document.getElementById("female").value);
  }
 }

</script>
<body >
 <div>
 <ul>sex:
  <li>man:<input type="radio" id="male" name="sex" value="man"/></li>
  <br/>
  <li>woman:<input type="radio" id="female" name="sex" value="woman"/></li>
  <br/>
 </ul>
  <button οnclick="genderShow()">showGender</button>
 </div>
</body>
</html> 

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP