<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<title>简易的单数字随机抽奖,抽取随机数的js特效代码</title>
</head>
<body>
<div id=\"num\"></div>
<input value=\"start\" id=\"start\" type=\"button\" />
<input value=\"stop\" id=\"stop\" type=\"button\" />
<script>
var num = document.getElementById(\"num\");
var start = document.getElementById(\"start\");
var _stop = document.getElementById(\"stop\");
var intv = null;
start.onclick = function(){
if(intv==undefined){
intv = setInterval(function(){num.innerHTML = Math.floor(Math.random()*10);},50);
}
}
_stop.onclick = function(){
clearInterval(intv);
intv=null;
}
</script>
</body>
</html>
我现在展示的是运行中截的图,是静止的,大家可以动手操作,感受一下,会有一点点的成就感哦。
以上就是本文的全部内容,希望大家可以继续深入学习。
本文地址:https://www.stayed.cn/item/16860
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我