0

i don't understand this

var arr = document. getElementsByTagName(""); for(var x=0; x<arr. ; x++) { } ; x++) { arr[x]. = "demo.jpg"; }

28th Apr 2019, 6:00 AM
GamingBase 854
GamingBase 854 - avatar
3 Answers
+ 1
There are some syntax errors in this code. But I think I can recreate it describe it to you var arr = document.getElementsByTagName("img"); //should be img according to the code. for(var x=0; x<arr.length ; x++) { arr[x].src = "demo.jpg"; } What happens in this code is that an array of HTMLElement containing img elements stored in a variable x. In next lines it transverse through all the images stored in that array and change the src attribute to demo.jpg. So if you run this code after placing some img tags in HTML you will get same image in all img elements
28th Apr 2019, 6:10 AM
Seniru
Seniru - avatar
+ 1
GamingBase 854 no it doesn't bother me. In that code you store the element with id par in a variable called par and element#node in var node
28th Apr 2019, 7:01 AM
Seniru
Seniru - avatar
0
thanks this answer really helped but i have another question, var par = document.getElementById("par"); var node = document.getElementById("node"); . ( ); i hope my questions do not bother you too much
28th Apr 2019, 6:51 AM
GamingBase 854
GamingBase 854 - avatar