A) С jQuery:
$("#quoteId").toggleClass('anime reve');
$(document).ready(function(){
$('button').click(function(){
$("#quoteId").toggleClass('anime reve');
})
})
.anime {
animation-name: example;
animation-duration: 5s;
}
.reve {
animation-name: reve;
animation-duration: 5s;
}
@keyframes example {
0% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: 1;}
}
@keyframes reve {
0% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: 1;}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div id="quoteId" class="reve" >
<h1>{{ data }}</h1>
</div>
<button>Show Next</button>
B) С Pure Css:
Примечание: применяется: активный селектортолько при нажатой кнопке.
Вы должны немного изменить html-код после использования active
селектора.
button:active + #quoteId {
animation-name: example;
animation-duration: 20s;
}
@keyframes example {
0% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: 1;}
}
button:active + #quoteId {
animation-name: example;
animation-duration: 1s;
}
.container {
position: relative;
padding-bottom: 20px;
}
button {
position: absolute;
bottom: 0;
}
<div class="container">
<button>Show Next</button>
<div id="quoteId">
<h1>{{ data }}</h1>
</div>
</div>