function waitExe(param){
    if(time < 20){
        time ++;
        $("#content").html(time);
        var self=this;
        timeout = window.setTimeout(function(){
            self.waitExe(param)
        }, 2000)
    }else{
        alert(param);
        clearTimeout(timeout);
    }
}
function f_testSetTimeOut(){
    time = 0;
    waitExe('gg');
    $("#content").html('---------');
}
<input type="button"  value="setTimeOut测试" onclick="f_testSetTimeOut();"/>
<div id="content">--</div>

 

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2021-10-07
  • 2021-11-07
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案