事件的注册
<head>
<script type="text/javascript">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body id="body">
</body>
常用的事件
<head>
<script type="text/javascript">
function clickTest(){
alert("单击..");
}
function dbClick(){
alert("双击..");
}
function showTime(){
var timeSpan = document.getElementById("timeSpan");
var date = new Date().toLocaleString();
timeSpan.innerHTML = date.fontcolor("red");
}
function hideTime(){
var timeSpan = document.getElementById("timeSpan");
timeSpan.innerHTML = "";
}
function showInfo(){
var timeSpan = document.getElementById("userName");
timeSpan.innerHTML = "用户名是由6位的英文与数字组成".fontcolor("green");
}
function hideInfo(){
var timeSpan = document.getElementById("userName");
timeSpan.innerHTML = "";
}
function change(){
alert("城市改变了..");
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<input type="button" onclick="clickTest()" value="单击" />
<input type="button" ondblclick="dbClick()" value="双击"/>
<span onmousemove="showTime()" onmouseout="hideTime()" >查看当前系统时间:</span><span id="timeSpan"></span>
用户名<input type="text" onfocus="showInfo()" onblur="hideInfo()" /> <span id="userName"></span>
<select onchange="change()" >
<option>郑州</option>
<option>重庆</option>
<option>杭州</option>
</select>
</body>