您的位置:首页 > Web前端 > HTML

html之radio是否被选中的判断------radio只是input的type属性

2016-02-27 23:07 686 查看
       少写文字, 直接用代码说话:

<html>

<body>

男性:<input type="radio" id="male" name="xxx"/>
<br />
女性:<input type="radio" id="female" name="xxx"/>
<br />

<button onClick="output()">test</button>

<script>
function output()
{
if(document.getElementById("male").checked)
{
alert("1");
}

if(document.getElementById("female").checked)
{
alert("2");
}
}
</script>

</body>
</html>
       搞定。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: