I have given btn
class separately to all buttons. I want to get all buttons using .getElementsByClassName("btn")
I know it return a ClassList. Next I want get a single button on which click event occur so that I wrote below code
let btn = document.getElementsByClassName("btn");
console.log(btn); // successfully got all buttons in a class list
btn.addEventListener("click",(event)=>{
let target_btn = event.target;
target_btn.style.boxShadow = "inset 0 -1px 16px 1px black";
target_btn.style.transition = "all 0.4s";
});
I want to get event occurred button (event.target) from ClassList so that I can add box-shadow & transition to that target button but unable to do.
In console, I also got Uncaught TypeError: btn.addEventListener is not a function