javascript来拿分吧

来源:百度知道 编辑:UC知道 时间:2024/05/31 18:34:46
<!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>
<script language="javascript">
id1.style.top=20;
id2.style.top=20;
id3.style.top=20;
id4.style.top=20;
id5.style.top=20;
id6.style.top=20;
id7.style.top=20;
id8.style.top=20;
id9.style.top=20;
id10.style.top=20;
id11.style.top=20;
id12.style.top=20;
function A(){
id1.style.top+=Math.round(Math.random()*5)+2;
id2.style.top+=Math.round(Math

id1.style.top=20; 在函数外部的定义不能影响函数内部

<script language="javascript">
var id_top1 = 20;

function A(){

id_top1 += Math.round(Math.random()*5)+2;
document.getElementById("id1").style.top=id_top1;

if(id_top1>=600)
id_top1=20;

setTimeout("A();",100)
}
</script>