为什么点击标题位置,弹窗是undefined
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
tr{text-align: center;}
</style>
<script type="text/javascript">
function sex(){
var d=document.getElementsByName("classsex")
alert(d.length);
}
function sum1(){
var f=document.getElementsByTagName("input")
alert(f.length);
}
function head1(){
var x=document.getElementById("header1").innerHTML;
alert(x.innerHTML)
}
</script>
</head>
<body>
<table border="1px" width="500px">
<tr>
<td>
学号:
</td>
<td>
<input type="text" name="classno" >
</td>
</tr>
<tr>
<td>
姓名:
</td>
<td>
<input type="text" name="classname" >
</td>
</tr>
<tr>
<td>
性别:
</td>
<td>男
<input type="radio" name="classsex" value="man">
女
<input type="radio" name="classsex" value="woman">
</td>
</tr>
<tr>
<td>
年龄:
</td>
<td>
<input type="text" name="classage" >
</td>
</tr>
<tr>
<td>
地址:
</td>
<td>
<input type="text" name="classadd" >
</td>
</tr>
</table>
<h1 id="header1" onclick="head1()">看看三种获取节点的方法?</h1>
<p>点击标题弹出它的值</p>
<input type="button" name="sex1" value ="看看name为sex的节点有几个?" onclick="sex()">
<input type="button" name="ok1" value="看看标签名为input的节点有几个?" onclick="sum1()">
</body>
</html>