js休眠

<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery.min1.3.2.js" charset="utf-8"></script>
<title>休眠</title>

<script language="javascript">
function sleep(time){

i=1;

id=setInterval(b,time);

function b(){

if(i<=10){
$("p").html("aa"+i);
i++;

}

else{

clearInterval(id);

}

}
alert("sleep: "+time);

}

</script>

<body onload="javascript:sleep(3000);">
<p></p>
</body>
</html>

原文地址:https://www.cnblogs.com/shz365/p/3527899.html