你好我是新来的JavaScript,我试图写出一些测试网站的代码,我有一些问题,下面的道琼斯是我的代码和我不断收到这个错误,我不明白为什么。Js,document.getElementById(“ID”)。innerHTML,错误
TypeError: null is not an object (evaluating 'document.getElementById("h3").innerHTML = "<h3>You Are up to date!</h3>"')
这是我的第二种方法我尝试使用。我试图做的事情有一个版本列表,这是我的第一个版本列表,它会拉一个.js文件并建立一个表格,但那不起作用,所以我想我会试试这个,但是猜猜看是什么发生了什么?不工作
我现在使用的代码如下。如果你能提供帮助,那将是惊人的。 感谢,Dakmessier
var current = "1.0";
function get_latest(){
document.getElementById("bob").innerHTML = current;
}
if (local != current){
document.getElementById("Get").innerHTML = "<button><a href=\"bla\">Get the Latest Update!</a></button>";
} else if (local == current){
document.getElementById("h3").innerHTML = "<h3>You Are up to date!</h3>";
} else {
document.getElementById("h3").innerHTML = "<h3>Sorry, unable to check for update.</h3>";
}
有ID为'h3'没有元素,这是一个标记名 – adeneo
以及我增加了一个ID,这是H3,但我一直与我的代码,并已删除该ID和我现在更新上面的代码 – Dakmessier
你已经展示了你的JavaScript,你能否展示JavaScript预期能够工作的相关HTML? –