<!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>JS 监听按钮单击事件</title>
</head>
<body>
<input name="btnClick" type="button" id="btnClick" value="点我"/>
<script type="text/javascript" language="javascript">
//此JS代码必须放到body结束之前才有效
function $(id){return document.getElementById(id);}
$("btnClick").onclick = function(){alert("我被激活啦!");}
</script>
</body>
</html>