I have a page that has three buttons in three containers. The first button in each container has the same id
, the second button in each container has the same id
, and the third button in each container has the same id
. I have a Javascript
script that accepts incoming information and changes the color of the text in the buttons accordingly. Unfortunately when the script senses that a change needs to be made and attempts to apply the corresponding CSS, only the buttons in the first container get the CSS applied. I'm really not understanding why every element with the same id
is not getting the CSS applied to it.
The Javascript
action:
document.getElementById('button_1').className = "buttonActive";
The button elements:
<button id="button_1" class="button"><span id="button_text_1">Button 1</span></button>
<button id="button_2" class="button"><span id="button_text_2">Button 2</span></button>
<button id="button_3" class="button"><span id="button_text_3">Button 3</span></button>
<button id="button_1" class="button"><span id="button_text_1">Button 1</span></button>
<button id="button_2" class="button"><span id="button_text_2">Button 2</span></button>
<button id="button_3" class="button"><span id="button_text_3">Button 3</span></button>
<button id="button_1" class="button"><span id="button_text_1">Button 1</span></button>
<button id="button_2" class="button"><span id="button_text_2">Button 2</span></button>
<button id="button_3" class="button"><span id="button_text_3">Button 3</span></button>