淡入/淡出功能的连续循环 [英] Continuous loop of fade in/out function

查看:75
本文介绍了淡入/淡出功能的连续循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在连续循环中运行以下函数,但我认为这对我有用,但并非如此,因为该函数只运行一次.我不确定问题出在方法,间隔还是我的代码上.我对此很陌生.

I have the following function that I would like to run on a continuous loop and I thought this would work for me, but not so because the function only runs once. I am not sure if the problem is with the method, the interval or my code. I am fairly new at this.

var c = $(".test p").length;    
setInterval(faderepeat(c),20000);

function faderepeat(c){     
  var i = 0;
  while (i<=c) {
var p = $(".para");
($(p[i]).delay(i*3000).fadeIn(2000).fadeOut(1000));
  i++;
    }
}

推荐答案

将setInterval调用更改为:

Change your setInterval call to:

setInterval( function() { faderepeat(c); }, 20000);

调用方式,该函数运行一次,而setInterval反复调用该函数的结果.

The way you are calling it, the function runs once and setInterval calls the result of the function repeatedly.

这篇关于淡入/淡出功能的连续循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆