Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
clearTimeout()在jquery中不工作_Jquery_Settimeout_Cleartimeout - Fatal编程技术网

clearTimeout()在jquery中不工作

clearTimeout()在jquery中不工作,jquery,settimeout,cleartimeout,Jquery,Settimeout,Cleartimeout,//下面给出的代码是使用setTimeout()的循环函数 //我想在变量playerLifeecan可以创建fiddle?@vijith时停止此setTimeout(),您可以使用.stop()停止匹配元素上当前运行的动画。请在stop()之后尝试clearTimeout()。@Bhum这是我正在制作的一个小型打字游戏的一部分,数组中的单词将在屏幕上不同的位置随机生成,所有这些随机生成和所有内容都在gameengine()中,它通过代码中提到的setTimeout()连续运行,当playerL

//下面给出的代码是使用setTimeout()的循环函数


//我想在变量playerLifeecan可以创建fiddle?@vijith时停止此setTimeout(),您可以使用.stop()停止匹配元素上当前运行的动画。请在stop()之后尝试clearTimeout()。@Bhum这是我正在制作的一个小型打字游戏的一部分,数组中的单词将在屏幕上不同的位置随机生成,所有这些随机生成和所有内容都在gameengine()中,它通过代码中提到的setTimeout()连续运行,当playerLife值达到0时,我想停止settimeout函数以停止,但在这里settimeout仍在工作,并且单词仍在继续生成,我在if语句中添加了一个警报,当playerLife小于1时,它会工作,但clearTimeout仍然不可用working@VeenaK.Suresh我使用了问题中提到的clearTimeout,但它不起作用,gameEngine函数正在使用setTimeout()连续运行,我想在if条件变为true时停止该操作!,谢谢,如果你能制作一把小提琴来显示问题,那就太好了。我可以在clearTimeout功能之前看到控制台。这算是一种安慰吗?
if(gameLevel==1){
        x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 3000);
    }else if(gameLevel==2){
        x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 2500);
    }
    else if(gameLevel==3){
        x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 2000);
    }
    else if(gameLevel==4){
        x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 1500);
    }
    else if(gameLevel==5){
        x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 1000);
    }
if(playerLife<1)
    {
        console.log(playerLife);
      clearTimeout(x);


    }