Can you please take a look at This Demo and let me know how I can use the .removeClass(animated fadeIn)
or add fadeOut
class to the element after loading each item of the text array?
basically what I want to do is adding fade in and out for each element of array on appearing on the box .changeText
<div class="changeText" >Welcome</div>
<script>
$(function () {
var text = ["Welcome", "Hi", "Sup dude"];
var counter = 0;
setInterval(change, 3000);
function change() {
$(".changeText").html(text[counter]).addClass('animated fadeIn');
counter++;
if(counter >= text.length) { counter = 0; }
}
});
</script>
You can remove the animation bu using
$('#yourElement').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', doSomething);
It will trigger on animation is done.
You can use fadeIn()
and fadeOut()
for this:
$(function () {
var text = ["Welcome", "Hi", "Sup dude"];
var counter = 0;
setInterval(change, 3000);
function change() {
$(".changeText").fadeIn(500).html(text[counter]).fadeOut(500);
counter++;
if(counter >= text.length) { counter = 0; }
}
});
500
to change the speed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.