Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
118 views
in Technique[技术] by (71.8m points)

javascript - 在javascript中执行函数无限(execute a function infinity in javascript)

I am trying to fade in a spinner infinity.

(我试图在微调器无穷大中淡出。)

But spinner will fade out after a time because infinity is not working.

(但是微调器会在一段时间后淡出,因为无穷大不起作用。)

My code as follows.

(我的代码如下。)

setInterval(function(){
        console.log("fergergerg");
        $("#spinner").fadeIn();
},Infinity);

Where I was wrong and how can I make my spinner to be faded in always?

(我哪里错了,我怎样才能让我的微调,以在始终褪色?)

Simply I needed something like below.

(我只需要以下内容。)

while(true){
   $("#spinner").fadeIn();
}

But it also not working.

(但这也行不通。)

  ask by Zone Duo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
The solution is here, the below function executes "load" function every 1000 ms (every 1 sec) for ever and infinite.

function load(){
    $("#spinner").fadeIn();
    setTimeout(load, 1000);
}; load();

you can change the interval time as you want.

(您可以根据需要更改间隔时间。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...