js点击事件demo

来源:互联网 发布:spss如何输入数据 编辑:程序博客网 时间:2024/05/18 22:42

<!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>
<input id="btn1" type="button" value="哈哈" />

<input id="btn2" type="button" value="嘻嘻" />

<input id="btn3" type="button" value="啦啦" />

<input id="btn4" type="button" value="嘿嘿" />

<script type="text/javascript">

var xh={};

xh.btn1=document.getElementById("btn1");

xh.btn2=document.getElementById("btn2");

xh.btn3=document.getElementById("btn3");

xh.btn4=document.getElementById("btn4");

window.onload=function(){

 xh.btn1.onclick=function(){


 var jg=Math.round(Math.random()*30);

  xh.btn2.value=jg;
 alert("hello");//弹出提示框
 
 }
 xh.btn2.onclick=function(){


 var jg=Math.round(Math.random()*40);

  xh.btn3.value=jg;
 }
  xh.btn3.onclick=function(){


 var jg=Math.round(Math.random()*50);

  xh.btn4.value=jg;
 }
  xh.btn4.onclick=function(){


 var jg=Math.round(Math.random()*60);

  xh.btn1.value=jg;
  xh.btn2.value=jg;
  xh.btn3.value=jg;
  xh.btn4.value=jg;
 }
}
</script>


</body>
</html>

1 0
原创粉丝点击