How can I repeat an animation which is set with CSS and Javascript by onclick?
I am a very beginner code writer and know HTML, CSS and Javascript. I do not know why the following online click and function just work once. I will appreciate if you help me.
Code
function discharge() {
document.getElementById("electron").style.visibility = "visible";
document.getElementById("electron").style.WebkitAnimation = "mymove 5s 1 backwards"; // Code for Chrome, Safari, and Opera
document.getElementById("submit").style.backgroundColor = "lightblue";
document.getElementById("submit").style.boxShadow = "0px 3px 3px red";
document.getElementById("submit1").style.backgroundColor = "#4CAF50";
document.getElementById("submit1").style.boxShadow = "0px 0px 0px red";
}
#electron {
position: relative;
left: -10px;
visibility: hidden;
}
@-webkit-keyframes mymove {
0% {
left: 0px;
top: 0px;
}
25% {
left: -32px;
top: 0px;
}
50% {
left: -32px;
top: -20px;
}
75% {
left: 158px;
top: -20px;
}
100% {
left: 158px;
top: 5px;
}
}
<div>
<button id="submit" onclick="discharge()">Discharge</button>
<button id="submit1">charge</button>
</div>
<div id="electron">
<br /><i class="fa fa-minus-circle"></i>
<br /><i class="fa fa-minus- circle"></i>
<br />
</div>
charge()?