事件

来源:互联网 发布:淘宝加盟骗局 编辑:程序博客网 时间:2024/04/28 05:37
  • onclick 单击
  • ondblclick 双击
  • onfocus 元素获得焦点
  • onblur 元素失去焦点
  • <html><head></head><body><div style="background-color:green;width:200px;height:50px;margin:20px;padding-top:10px;color:#ffffff;font-weight:bold;font-size:18px;text-align:center;"onmouseover="this.innerHTML='good'"onmouseout="this.innerHTML='you have moved out'">move your mouse to here</div></body></html>


  •  onmouseover 鼠标移到某元素之上
  • onmouseout 鼠标从某元素移开

  • onmousedown 鼠标按钮被按下
  • onmouseup 鼠标按钮被松开
  • <html><head>  <script>    function mDown(obj)    // 按下鼠标 的 事件处理程序    {    obj.style.backgroundColor="#1ec5e5";    obj.innerHTML="release your mouse"    }    function mUp(obj)     // 松开鼠标 的 事件处理程序    {    obj.style.backgroundColor="green";    obj.innerHTML="press here"    }  </script></head><body><div style="background-color:green;width:200px;height:35px;margin:20px;padding-top:20px;color:rgb(255,255,255);font-weight:bold;font-size:18px;text-align:center;"onmousedown="mDown(this)"onmouseup="mUp(this)">press here</div></body></html>


  • onkeydown 某个键盘按键被按下
  • onkeyup 某个键盘按键被松开
  • onkeypress 某个键盘按键被按下并松开     
原创粉丝点击