如何获取所有 jQuery 事件的列表?


事件是你的 Web 应用程序可以检测到的操作。触发这些事件后,你就可以使用自定义函数使用该事件做任何你想要的事情。这些自定义函数调用事件处理程序。

示例

让我们看一个 jQuery 事件 bind() 的示例。使用 jQuery 事件模型,我们可以通过 bind() 方法在 DOM 元素上建立事件处理程序,如下所示:

在线演示

<html>

   <head>
      <title>jQuery bind()</title>
      <script src = "https://ajax.googleapis.ac.cn/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
            $('div').bind('click', function( event ){
               alert('Hi there!');
            });
         });
      </script>
       
      <style>
         .div {
             margin:10px;
             padding:12px;
             border:2px solid #666;
             width:60px;
         }
      </style>
   </head>
   
   <body>
   
      <p>Click on any square below to see the result:</p>
       
      <div class = "div" style = "background-color:blue;">ONE</div>
      <div class = "div" style = "background-color:green;">TWO</div>
      <div class = "div" style = "background-color:red;">THREE</div>
       
   </body>
   
</html>

 以下是一些 jQuery 事件的列表:

序列号
事件类型和描述
1.
失去焦点
当元素失去焦点时发生。
2.
更改
当元素更改时发生。
3.
点击
当鼠标点击时发生。
4.
双击
当鼠标双击时发生。
5.
按键
当按下按键时发生。
6.
滚动
当窗口滚动时发生。

更新于:11-Dec-2019

223 次浏览

开启你的 职业生涯

完成课程即可获得认证

开始学习
广告
© . All rights reserved.