javascript animations code example

Example 1: js add animation to element

document.getElementById('test').style.animation = 'fading 2s infinite'

Example 2: js animation

You can learn js animation from here
https://www.w3schools.com/howto/howto_js_animate.asp

Example 3: how to add animation over image in Javascript

function startAnimation() {
    var frameHeight = 102;
    var frames = 15;
    var frame = 0;
    var div = document.getElementById("animation");
    setInterval(function () {
        var frameOffset = (++frame % frames) * -frameHeight;
        div.style.backgroundPosition = "0px " + frameOffset + "px";
    }, 100);
}