+ 1
Why doesn't it work?
https://code.sololearn.com/Wr2fLhsnBAfM/#html I can't understand how I can change the content of the heading into the clock
5 ответов
+ 4
myArray[0].innerHTML = hour + ":" + minutes + ":" + seconds;
Change myArray to myArray[0] Karak10
ByTagName returns an array....
+ 2
var myArray = document.getElementsByTagName("h1"); selects a list of elements. That why you will be needed to say which with an index.
myArray[0].innerHTML = hour + ":" + minutes + ":" + seconds;
+ 1
Not much know about it but tried this way and it is working...Karak10
i think may it can be done by other ways also..
$(function() {
$("h1").click(function() {
t = document.querySelector("h1");
this.innerHTML= Date() ;
});
});
+ 1
Karak10 Use a for loop
for (var i = 0; i < myArray.length; i++) {
myArray[i].innerHTML = hour + ':' + minutes + ':' + seconds;
}
0
Jayakrishna🇮🇳 is there a way to make it so it applies to all headings then?