Javascript 多次使用setTimeout()时出现问题

Javascript 多次使用setTimeout()时出现问题,javascript,jquery,Javascript,Jquery,嘿,伙计们,我正试图像这样使用mutliple setTimeout(): setTimeout(function() { $('#hoverbox h2').html("..."); $('#hoverbox p').html("\..."); },0) setTimeout(function() { $('#hoverbox h2').html(".."); $('#hoverbox p').html("..."); },3500) setTimeou

嘿,伙计们,我正试图像这样使用mutliple setTimeout():

setTimeout(function()
{ 
    $('#hoverbox h2').html("...");
    $('#hoverbox p').html("\...");
},0)

setTimeout(function()
{ 
    $('#hoverbox h2').html("..");
    $('#hoverbox p').html("...");
},3500)

setTimeout(function()
{ 
    $('#hoverbox h2').html("...");
    $('#hoverbox p').html("...");
},3500)
我刚把
我原来有文本。。。所以问题是,当我运行这个程序时,它会从第一个开始,而不是等待3500 mili,然后直接跳到底部


请让我知道如何阻止这一切

您的第二个和第三个
设置超时
同时运行(几乎)。您可以将
7000
延迟放在第三位,或在第二位内初始化第三位
setTimeout

 setTimeout(function () {
     $('#hoverbox h2').html("...");
     $('#hoverbox p').html("\...");
 }, 0)

 setTimeout(function () {

     $('#hoverbox h2').html("..");
     $('#hoverbox p').html("...");
     setTimeout(function () {

         $('#hoverbox h2').html("...");
         $('#hoverbox p').html("...");
     }, 3500)

 }, 3500)

您的第二个和第三个
setTimeout
同时运行(几乎)。您可以将
7000
延迟放在第三位,或在第二位内初始化第三位
setTimeout

 setTimeout(function () {
     $('#hoverbox h2').html("...");
     $('#hoverbox p').html("\...");
 }, 0)

 setTimeout(function () {

     $('#hoverbox h2').html("..");
     $('#hoverbox p').html("...");
     setTimeout(function () {

         $('#hoverbox h2').html("...");
         $('#hoverbox p').html("...");
     }, 3500)

 }, 3500)

你期待什么?第二个和第三个块都有3500毫秒的延迟。第一个块不需要使用
设置超时
函数。@PraveenKumar,他可能需要这个函数,具体取决于上下文如果使用jQuery,为什么不使用
.delay()
?@Derek朕會功夫 因为
.delay()
只对动画队列有效。您期望什么?第二个和第三个块都有3500毫秒的延迟。第一个块不需要使用
设置超时
函数。@PraveenKumar,他可能需要这个函数,具体取决于上下文如果使用jQuery,为什么不使用
.delay()
?@Derek朕會功夫 因为
.delay()
只适用于动画队列。谢谢大家,我的人!!!!所有你的朋友,谢谢!!!!