javascript - 错误Js无法读取null的 'setAttribute'属性

标签 javascript compiler-errors

它说:

index.html:50 Uncaught TypeError: Cannot read property 'style' of null in function document.getElementById("bp_infinity").style.display = "block";



http://i.stack.imgur.com/hODMO.png

非常感谢您的回答。

最佳答案

DOM准备就绪之前,JS正在执行。

要么将<script>标记移到</body>结束标记之前,要么将所有Javascript放在onload函数中,例如.. window.onload = function(){ /** all code goes here **/};

关于javascript - 错误Js无法读取null的 'setAttribute'属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39839382/

相关文章:

c++ - 在 Visual Studio 2019 MSVC 中编译时出现编译错误 C2048,但在 clang++ 中可以正常工作吗?

c++ 编译错误 "redefinition of",需要帮助才能找到它

android - 错误:unknown command crunch

javascript - "anonymous"周的开放时间/全日历

javascript - 禁用空输入的发送按钮

javascript - 使用 JavaScript 从 HTML 创建 PDF 文档

javascript - 我怎样才能在一个循环中扭转这个困惑局面?

javascript - 你如何为 bool 检查器编写这个 if/else 语句

java - 编译java的小麻烦

swift - Swift编译器对Bool (“”)意味着什么奇怪的消息?