1
[JAVASCRIPT] getElementByID() is not getting all tagged elements
YatinBayya (3)

When you change a style of a certain ID, javascript is only picking up the first div

<div id="myID" style="width:100px;height:100px;"></div>
<div id="myID" style="width:100px;height:100px;"></div>
<div id="myID" style="width:100px;height:100px;"></div>

In javascript

document.getElementByID("myId").style.backgroundColor="red";

If anyone can help me that would be appriciated

You are viewing a single comment. View All
Answered by vedprad1 (461) [earned 5 cycles]
View Answer
1
YatinBayya (3)

@vedprad1 but when you say getElementByClassName() it is actually a list so you need to loop through it