<!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=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="rrr"></div>
<script language="javascript">
var i=0;
while(i<100000)
{document.getElementById("rrr").innerHTML=i;
i++;
}
</script>
</body>
</html>
我想在id为rrr的div层里动态显示数字,就像123456789这样,数字在一个地方不断变换,可是出来的效果是直接显示99999,不能动态显示
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="rrr"></div>
<script language="javascript">
var i=0;
while(i<100000)
{document.getElementById("rrr").innerHTML=i;
i++;
}
</script>
</body>
</html>
我想在id为rrr的div层里动态显示数字,就像123456789这样,数字在一个地方不断变换,可是出来的效果是直接显示99999,不能动态显示
你的代码是不能做出你要的效果的。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="JavaScript">
/////////////
//循环执行
function exec() {
window.setInterval("show()",1000);
}
//输出数字
function show() {
var num=RndNum(4);
document.getElementById("rrr").innerHTML=num;
}
//随机数
function RndNum(n){
var rnd="";
for(var i=0;i<n;i++)
rnd+=Math.floor(Math.random()*10);
return rnd;
}
</script>
<body>
<div id="rrr">测试</div>
<script>
exec();
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="rrr"></div>
<script language="javascript">
var i=0;
while(i<100000)
{show(i);
i++;
}
function show(n){
rrr.innerHTML=i;
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="rrr"></div>
<script language="javascript">var $ = function($){return document.getElementById($)}
var i=1;obj=$('rrr')
var tm = setInterval(function(){
if(i == 10000){clearInterval(tm);tm=null;}
obj.innerHTML = i++;
},1000)
</script>
</body>
</html>