JavaScript 中出现 Uncaught TypeError: Cannot read property 'XXX' of null的解决思路
我代码中的情况
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
let button = document.getElementById("myButton");
button.focus();
console.log(document.activeElement === button); // true
</script>
<div class="bd user disabled">...</div>
<button id="myButton">as</button>
</body>
</html>