HTML选择结构为什么会出现该种错误

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function s()
{
if(person.sex.value=="男")
{
alert("先生您好")
;}
else
{
alert("女士您好");}
}
</script>
<title>无标题文档</title>
</head>

<body>
<form name="person">
<input type="radio" name="sex" value="男" checked>男
<input type="radio" name="sex" value="女">女<br>
<input type="button" value="确定" onClick="s()">
</form>
</body>
</html>

试试这么写。。

for(var i = 0;i<person.sex.length;i++){
if(person.sex[i].checked){
console.log(person.sex[i].value)
return;
}
}

温馨提示:答案为网友推荐,仅供参考
相似回答