【发布时间】:2015-10-15 14:19:34
【问题描述】:
示例代码
document.body.getAttribute.apply(this,['id']);
document.body.setAttribute.apply(this,['id','test']);
错误
火狐:
TypeError:在未实现接口 Element 的对象上调用了“setAttribute”。
铬:
未捕获的类型错误:非法调用
【问题讨论】:
-
你从
console.log(this)得到什么,因为Firefox的错误信息清楚地表明this不是一个元素。
标签: javascript dom