日期:2014-05-16 浏览次数:20404 次
<!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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>ok</title>
<script type="text/javascript" src="js.js"></script>
</head>
<body>
<form action="#" >
<input type="button" id="Nihao" value="你好" />
<input type="button" id="Woqu" value="我好" />
<input type="button" id="Dajiahao" value="大家好" />
</form>
</body>
</html>
window.onload = initAll;
function initAll() {
document.getElementById("Nihao").onclick = chuLi;
document.getElementById("Wohao").onclick = chuLi;
document.getElementById("Dajiahao").onclick = chuLi;
}
function chuLi() {
switch (this,id) {
case "Nihao":
alert("你好");
break;
case "Wohao":
alert("我好");
break;
case "Dajiahao":
alert("ssssss");
break;
default:
}
}