<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <div id="sj"></div> <input type="button" value="开始" onclick="ShowNumber()" /> </body> <script type="text/javascript"> var arr = new Array( "0","1","2","3","4","5","6","7","8","9" ); var bs = 0; function ShowNumber() { var bian = Math.floor( Math.random()*10); var s = document.getElementById("sj"); s.innerText = arr[bian]; bs = bs+1; //s.innerText = bs; if(bs==5) { window.clearTimeout(jian); } else { var jian = window.setTimeout("ShowNumber()",30); } } </script> </html>
点击开始按钮后,会得到一个随机数,刷新之后还可以得到另一个
时间: 2024-10-06 18:56:22