【发布时间】:2017-01-20 07:12:57
【问题描述】:
我认为document.getElementById 是一个函数。
所以这个函数可以赋值给变量。像这样
var hello = document.getElementById;
console.log(hello('hello')));
<div id="hello">hello</div>
但它发生了这样的错误:
未捕获的类型错误:非法调用
【问题讨论】:
-
var hello = document.getElementById('hello');console.log(hello) -
你到底想做什么?
-
该方法必须知道您希望在哪个
Document实例上调用它。可能是document
标签: javascript document getelementbyid