0
why i cannot call this function?
function a() { var d = new Date() var a = d.getSeconds() var b = d.getMilliseconds() document.body.innerHTML = `${a}:${b}` } a()
6 ответов
+ 4
5th line is invalid. You need to do this:
document.getElementsByTagName("body")[0].innerHTML = "Something";
You also need to wait until the DOM loads the page, so you have to do something like this:
window.onload = a;
and remove the line with a();
+ 4
Oh, I see.
Fixed.
+ 3
S Pace Oh, I am not an expert in JS, so I wrote that just to make sure.
+ 3
I am not an expert @Jan Štěch
+ 2
Jan Štěch
document.body works !