0

Where is my mistake?

function setText() { var a = document.getElementById("demo"); var arr = a.childNodes; for (var x=0; x<arr.length;x++){ arr[0].innerHTML = "its me" } } setTimeout(setText(), 120)

16th Jul 2020, 3:15 AM
Harry star
Harry star - avatar
5 odpowiedzi
+ 2
In the last line.... You no need to put parenthesis after function name...
16th Jul 2020, 3:27 AM
Mustafha Ahmad
Mustafha Ahmad - avatar
+ 1
Can you tell what error are you getting?
16th Jul 2020, 3:54 AM
Gyan Prakash Singh Jaruhar
Gyan Prakash Singh Jaruhar - avatar
+ 1
Recheck the loop, you always use 0 (zero) as element index there. I'm guessing you meant to pass <x> instead like this 👇 arr[x].innerHTML = "it's me"; (Corrected - Thanks to Ja Play)
16th Jul 2020, 4:07 AM
Ipang
+ 1
I think it should be arr[x].innerHTML = „its me“;
16th Jul 2020, 6:36 AM
JaScript
JaScript - avatar