问题很简单,但令我感到困惑的是,当我的console.log(document.body)或(document.head)都工作正常但是当我使用document.script或document.html这两个不工作时为什么?虽然所有这些都在文件中?
Q2)我可以写
document.getElementById('something')Run Code Online (Sandbox Code Playgroud)
但为什么我不能写
document.body.getElementById('something')Run Code Online (Sandbox Code Playgroud)
虽然body也在body标签中的文档和元素中,但有时document.body在脚本的不同阶段工作