为什么我会收到错误或 Uncaught TypeError: Cannot set property 'innerHTML' of null?我以为我理解了 innerHTML 并且以前使用过它。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>
<script type ="text/javascript">
what();
function what(){
document.getElementById('hello').innerHTML = 'hi';
};
</script>
</head>
<body>
<div id="hello"></div>
</body>
</html>