当前位置: 代码迷 >> JavaScript >> js统制onclick事件实例
  详细解决方案

js统制onclick事件实例

热度:128   发布时间:2012-11-23 22:54:33.0
js控制onclick事件实例
<html>
	<head> 
  </head>
<body>
	<button id="a1">点击</button>
	<script>
	function test(){
		document.getElementById("a1").onclick=function(){alert('this is a1');};
		//下面这种写法是不对的
		//document.getElementById("a1").onclick="alert('this is a1');";
	}
	test();
</script>
</body>
</html>
?

?

  相关解决方案