<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title></title>
</head> <body>
<input type="checkbox" id="input" >000</input>
<script type="text/javascript">
var h1s=document.getElementById("input");
var t=h1s.firstChild.nodeValue;
alert(t);
</script>
</body>
</html>
我的思路:先访问到input节点,然后“000”做为input的第一个子节点,然后输出这个子节点的值。
但是老是提示出错
<head>
<title></title>
</head> <body>
<input type="checkbox" id="input" >000</input>
<script type="text/javascript">
var h1s=document.getElementById("input");
var t=h1s.firstChild.nodeValue;
alert(t);
</script>
</body>
</html>
我的思路:先访问到input节点,然后“000”做为input的第一个子节点,然后输出这个子节点的值。
但是老是提示出错
<input type="button" onclick="alert(document.getElementById('a').value);">
我想 var t=h1s.firstChild.nodeValue; 这句有问题的话,
可以直接用h1s.value就可以了