简体   繁体   English

关于使用Animate.css向项目中添加和删除Animate类的问题

[英]Issue on Adding and Removing Animate Class to and item using Animate.css

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? 您能否看一下本演示 ,让我知道加载文本数组的每个项目后如何使用.removeClass(animated fadeIn)或向元素添加fadeOut类?

basically what I want to do is adding fade in and out for each element of array on appearing on the box .changeText 基本上我想做的是为出现在盒子上的数组的每个元素添加淡入和淡出.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 您可以使用以下方法删除动画bu

$('#yourElement').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', doSomething);

It will trigger on animation is done. 它将在动画完成时触发。

You can use fadeIn() and fadeOut() for this: 您可以fadeIn()使用fadeIn()fadeOut()

$(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; }
    }
});

Here is an Example 这是一个例子


Simply adjust the value of 500 to change the speed. 只需将值调整为500即可更改速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM