I have a project where I imported animate.css
so the transitions would be funnier, but one of them only occurs to me once.
var check = true;
$(document).ready(function(){
$(".p2").hide();
$("button").click(function(){
if(check){
$(".p1").show().removeClass().addClass("animated flipOutX").on('webkitAnimationEnd oanimationend msAnimationEnd animationend',
function(e) {
$(this).removeClass().hide();
$(".p2").show().addClass("animated flipInX");
});
} else {
$(".p2").show().removeClass().addClass("animated flipOutX").on('webkitAnimationEnd oanimationend msAnimationEnd animationend',
function(e) {
$(this).removeClass().hide();
$(".p1").show().addClass("animated flipInX");
});
}
check = !check;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkhref="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet"/>
<p class="p1">Click me away!</p>
<p class="p2">Click me too!</p>
<br>
<button class="btnFlip">Click</button>
As you can see in the code above, the animation is only done once and I wanted to replace a p
with another how many times I clicked on button