+ 2
Why wont this work?
Why wont this code change the h1 tag, it just stays at its default text entered in the html? var x = 1; var y = 1; var fib = document.getElementsByTagName("h1"); function increase() { x += y; y = x-y; fib.innerHTML = y ; } setInterval(increase, 1000);
2 ответов
+ 3
When you call document.getElementsByTagName("h1"), it returns an array of h1 tags; even if you have just one h1 tag.
You must use indexes, e.g. fib[0].innerHTML.
+ 2
Oh, youre right, thank you @Mohammad Amin Chitgarha