解决因`script`前置而造成的操作 DOM 报错

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <script>
      document.addEventListener("DOMContentLoaded", function () {
        console.log(document.body.innerHTML);
      });
    </script>
  </head>
  <body>
    <div>Hello, World!</div>
  </body>
</html>

posted on 2021-09-10 10:42  aisowe  阅读(77)  评论(0编辑  收藏  举报

导航