明辉站/网站教程/内容

html中input框中的radio是否被选中的判断

网站教程2023-12-28 阅读
[摘要]少写文字, 直接用代码说话:<html><body>男性:<input type="radio" id="male" name="xxx"/><br />女性:<input type=...
少写文字, 直接用代码说话:

<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>

搞定。

以上就是html中input框中的radio是否被选中的判断的详细内容,更多请关注php中文网其它相关文章!


网站建设是一个广义的术语,涵盖了许多不同的技能和学科中所使用的生产和维护的网站。

……

相关阅读