<button id="castBtn">呪いをかけろ</button>
<div id="box"></div>
<button id="removeBtn">呪いを解け</button>
#box {
width: 100px;
height: 100px;
background: steelblue;
margin-top: 16px;
}
.animated {
animation: henshin 1s infinite alternate;
}
@keyframes henshin {
from {
background: steelblue;
transform: scale(1);
}
to {
background: tomato;
transform: scale(1.5);
}
}
const removeBtn = document.querySelector('#removeBtn');
removeBtn.addEventListener('click', function() {
box.classList.remove('animated');
});
const btn = document.querySelector('#castBtn');
const box = document.querySelector('#box');
btn.addEventListener('click', function() {
box.classList.add('animated');
});