Add animation to a html content in JavaScript

Some times situation may arise where we have to add animation to HTML contents using JavaScript.

One situation is that if we have to change the display property of content to block and none ,we have to write script to it. What we will do if we need to add an animation while having change the display property.

lets look into an example:-

if (displaySetting == ‘block’) {
toggle.style.display = ‘none’;
}
else {
toggle.style.display = ‘block’;
}

If we want to add animation on changing the display, we can simply add

toggle.style.animation = “animation_effect”;

Leave a comment

Your email address will not be published. Required fields are marked *