事件例子

<!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>无标题文档</title>
<style type="text/css">
</style>
</head>

<body>

<input class="btn" id="anjiu" type="button" value="点击" />
<input class="btn" id="anjiu2" type="text" />

<!--<select onchange="show()">
<option>11</option>
<option>22</option>
<option>33</option>
<option>44</option>
</select>
-->

</body>
<script type="text/javascript">

/*var a=document.getElementById("anjiu");

a.onclick =function(){ //匿名函数
alert("aa");
}

var a1 =document.getElementById("anjiu2");
a1.onclick =function(){
alert("aa");
}*/

//JS不支持统一加事件
/*var btn =document.getElementsByClassName("btn");
btn.onclick =function(){
alert("aa");
}
*/

//关于鼠标的事件
//onlick 鼠标单击触发
//ondblclick 鼠标双击触发
//onmouseover 鼠标移上触发
//onmouseout 鼠标离开触发
//onmousemove 当鼠标移动时触发

//关于键盘的事件
//onkeydown 键盘按下触发
//onkeyup 按键抬起时触发
//onkeypress 按键触发


//关于表单的事件
//onfocus 获得焦点触发
//onblur 失去焦点触发
//onchange 内容改变触发

/*function show(){
alert("aa");
}*/

</script>
</html>

posted @ 2017-06-19 21:57  折剑公子  阅读(108)  评论(0编辑  收藏  举报