<html>
<head>
<script type="text/javascript">
(function() {
alert("here.....");
var ss = document.getElementById("cc").value;
alert("xxxxx= "+ss);
})()
</script>
</head>
<body>
<input type="checkbox" id = "cc" name="c" onclick="getit();" onmouseover="mouseover();" disabled>
</body>
<html>
因为DOM没有加载完成, 无法读取
value
.解决方法:
script
标签放底部ready()
onload
事件DEMO: