$('.flip-button').each(function() {
$(this).click(function() {
$(this).closest('.flip-card-inners').toggleClass('flip-card-active')
})
})
I wasn't able to translate this in vanilla js because I encountered several problems with get element by class
CodePudding user response:
document.querySelectorAll(".flip_button").forEach(element => {
element.onclick = () => {
element.closest('.flip-card-inners').classList.toggle("flip-card-active");
}
});
CodePudding user response:
document
.querySelectorAll('.flip-button')
.forEach((element)=> {
element.addEventListener("click", function(e) {
// Do your action
}, false);
})