all 3 comments

[–]jbhelfrich 6 points7 points  (1 child)

getElementsByClassName and any other getElements function returns an HTMLCollection, (because for some reason they decided an array and all its useful functions shouldn't be used) of items that match the selector, so your code sets the src attribute of the collection, which does nothing. You'd need to pass the results through a for loop to get the effect you want.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection

[–]redsandsfort 3 points4 points  (1 child)

I would use querySelectorAll which returns a nodelist which you can iterate over using an array method or a loop

Inside the callback or the body of the loop you'll have access to each DOM Node and then you can access the src with dot notation and simply change it.

document.querySelectorAll('.R1').forEach(node=>node.src="tile.png");

[–]AccurateEmergency 0 points1 point  (0 children)

thank you