There's aYou can use the toggle
method infrom Element.classList
that can be used like this in your example (also, checkand the animationend
event in your example:
<script>
Array.prototype.slice.call(document.querySelectorAll(".box")).forEach(function(el) {
el.addEventListener('click', click());
el.addEventListener('animationend', resetBox());
});
function click(e) {
return function(e) ={
e || window.event;
var target = e.target || e.srcElement;
if (target.addEventListener('animationend', functionclassList.contains('box')) {
if (thistarget.classList.contains('box-rest'active')) {
this.className = 'box'; target.classList.toggle('box-rest');
} else {
});
if ( target.classList.containstoggle('box')'box-active') {;
if (target.classList.contains('box-active')) { }
}
target.classList.toggle('box-rest') };
}
function resetBox() {
} else return function(e) {
var target = e.target || e.srcElement;
if (target.classList.togglecontains('box-active'rest');) {
} target.className = 'box';
}
}, false) };
}
</script>