I know you can change the class of a button using
document.getElementById("ID1").setAttribute("class", "NewClass");
But say i wanted to change the class to active
if the button is clicked, is there anyway to do this without assigning an ID to the buttons ?
I also don't want to change all buttons with this class and am aware you can use get element by class as well.
The buttons are generated by another piece of javascript and look like
<button class="btn" onclick="myFunction(this.innerHTML)">A</button>
<button class="btn" onclick="myFunction(this.innerHTML)">B</button>
<button class="btn" onclick="myFunction(this.innerHTML)">C</button>
<button class="btn" onclick="myFunction(this.innerHTML)">D</button>
<button class="btn" onclick="myFunction(this.innerHTML)">F</button>
<button class="btn" onclick="myFunction(this.innerHTML)">G</button>
Any help would be appreciated.
Also if you need any more information just let me know.