I have 3 buttons with same class(myBtn), I want to change the background color of the button I clicked using querySelectorAll and addEventListener.
I'm making a bigger project this is just an example of my problem, I'm into pure javascript and i don't wanna use onClick method in my html for some reason.
var a = document.querySelectorAll('myBtn')[2];
a.addEventListener("click", callFunc());
function callFunc() {
this.style.backgroundColor = "red";
}
<p>Click the button to change its background color.</p>
<button id="myBtn">uno</button>
<button id="myBtn">dos</button>
<button id="myBtn">tres</button>