2个回答
展开全部
<html>
<head>
<script type="text/javascript">
function WhichOneisChecked(obj) {
for (var i = 0;i < obj.elements.length;i++){
if (obj.elements[i].checked == true){
alert(i + "被选中");
}
}
}
</script>
</head>
<body>
<form>
<input type="radio" id="test" name="test" value="1" checked>
<input type="radio" id="test" name="test" value="2">
<br>
<button onClick="javascript:WhichOneisChecked(this.form);">检查状态</button>
</form>
</body>
<head>
<script type="text/javascript">
function WhichOneisChecked(obj) {
for (var i = 0;i < obj.elements.length;i++){
if (obj.elements[i].checked == true){
alert(i + "被选中");
}
}
}
</script>
</head>
<body>
<form>
<input type="radio" id="test" name="test" value="1" checked>
<input type="radio" id="test" name="test" value="2">
<br>
<button onClick="javascript:WhichOneisChecked(this.form);">检查状态</button>
</form>
</body>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询