how to add animation using javascript code example
Example 1: js add animation to element
let rotate360 = [
{ transform: 'rotate(360deg)' }
];
Example 2: js add animation to element
document.getElementById('test').style.animation = 'fading 2s infinite'
Example 3: js add animation to element
#test {
background-color: blue;
width: 100px;
height: 100px;
position: relative;
-webkit-animation: fading 5s infinite;
animation: fading 5s infinite;
}
@keyframes fading {
0% { opacity: 1; }
100% { opacity: 0; }
}