[英]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; }
}
});
500
to change the speed.
500
即可更改速度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.