Javascript 如何打破循环

Javascript 如何打破循环,javascript,html,Javascript,Html,圆圈 .圆圈{ 宽度:32px; 高度:32px; 边界半径:32px; 背景:黑暗 } 功能按功能(事件){ var x=事件,即:; if(parseInt(x,10)==119){ 跳跃(); } } 函数jumpup(){ document.getElementById(“demo”).innerHTML=“嘿” document.getElementById(“ball”).style.top=parseInt(document.getElementById(“ball”).styl


圆圈
.圆圈{
宽度:32px;
高度:32px;
边界半径:32px;
背景:黑暗
}

功能按功能(事件){ var x=事件,即:; if(parseInt(x,10)==119){ 跳跃(); } } 函数jumpup(){ document.getElementById(“demo”).innerHTML=“嘿” document.getElementById(“ball”).style.top=parseInt(document.getElementById(“ball”).style.top,10)+parseInt(10,10)+“px”; } 函数跳转(){ document.getElementById(“ball”).style.top=parseInt(document.getElementById(“ball”).style.top,10)+parseInt(-10,10)+“px”; document.getElementById(“演示”).innerHTML=“否” } var jumpingup=window.setInterval(函数(){ 跳起 }, 50); var jumpingdown=window.setInterval(函数(){ 跳下 }, 50); 函数跳转(){ 跳跃; 设置超时(清除间隔(跳跃),100); 跳下; setTimeou(清除间隔(跳下),100); }

圆圈
.圆圈{
宽度:32px;
高度:32px;
边界半径:32px;
背景:黑暗
}

功能按功能(事件){ var x=事件,即:; if(parseInt(x,10)==119){ 跳跃(); } } var jumpingdown=window.setInterval(函数(){ 跳下 }, 50); 清除间隔(跳下); 函数jumpup(){ document.getElementById(“demo”).innerHTML=“嘿” document.getElementById(“ball”).style.top=parseInt(document.getElementById(“ball”).style.top,10)+parseInt(-20,10)+“px”; } 函数跳转(){ document.getElementById(“ball”).style.top=parseInt(document.getElementById(“ball”).style.top,10)+parseInt(10,10)+“px”; document.getElementById(“演示”).innerHTML=“否” } 函数跳转(){ var jumpingup=window.setInterval(函数(){ 跳起 }, 30); setTimeout(函数(){ 清除间隔(跳跃) }, 230); var jumpingdown=window.setInterval(函数(){ 跳下 }, 30); setTimeout(函数(){ 清除间隔(跳下) }, 460); }
,提供您存储间隔的标识符(由
setInterval()返回).@JonathanLonowski,它实际帮助了我,因此我可以设置超时一段时间,然后清除间隔