there are 6 buttons
and 6 .details
pages.
The 1st button worked fine but 2nd and other buttons are not working.
You can Debug at Codepen https://codepen.io/sarthakg043-the-selector/pen/jOOVyNQ
I had already tried to solve this by writing tonnes of lines but I want a DRY code. Why isn't the second button working?
var page = document.querySelectorAll(".details");
var btn = document.querySelectorAll("button");
var book = document.querySelector(".card");
var place = 0;
for(var i = 0; i < btn.length; i++){
place = i;
btn[i].addEventListener("click", function(){
page[place].style.transform = "rotateY(-135deg)";
});
}
book.addEventListener("mouseleave", function(){
for(var i = 0; i < page.length; i++){
place = i;
page[i].style.transform = "";
}
});