如果我必须在Chrome扩展的新选项卡的页面元素上插入一些值,该怎么办?getElementsByClassName(className)返回null
我使用:
document.getElementsByClassName("quotes").innerHTML = Quotes[x];
在newtab-script.js
页,但它显示在控制台此错误:
Uncaught TypeError: Cannot set property 'innerHTML' of null
我的页面包含一个名为quotes
类div
但是当我提醒这个:
document.getElementsByClassName("quotes")
The resul t是null
。
我的代码的格式为:
window.onload = function abc(){
alert(document.getElementById('a'));
document.getElementById('a').innerHTML ="ishaan";
}
我输入我的脚本文件,在其中覆盖谷歌Chrome的新标签页一个HTML页面。我的脚本在脚本文件上。
”在控制台显示一些违规错误“该死的很难只是在这里粘贴错误 – madalinivascu
未捕获的类型错误:无法设置属性'innerHTML'为空 – Maverick
并且您拥有它行情[x]为空 – madalinivascu