1
I have a project that I’ve imported animate.css
so that 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>
<link href="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 it is possible to see in the code above, the animation is only done once and I wanted it to replace one p
for another how many times I clicked on button
This is happening constantly I just want to click the button to flipOutX one p and flipInX another p , IE, disappear one p and appear another in the same place.
– Bruno Gibellino
@Brunogibellino I edited the answer check the example again, put this comment in your question, why it is the goal of it, always try to create questions as clearly as possible.
– Gabriel Rodrigues