Files
notes_estom/JavaScript/jQuery/2事件.md
2020-07-21 09:13:01 +08:00

43 lines
891 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1 常见事件
> jquery对事件进行了重新封装。采取了与原生JS完全不同的事件处理方法。JS是在HTMLDOM元素中个添加事件属性将事件属性与事件响应函数绑定的方法完成事件响应机制。
> jquery大多数DOM事件都有一个等效的jQuery方法对应。调用jQuery对象的事件函数传递高阶函数作为参数用于回调。实现事件响应与主进程的异步通信。
### 鼠标事件
* click
* dblclick
* mouseenter
* mouseleave
* hover
### 键盘事件
* keypress
* keydown
* keyup
### 表单事件
* submit
* change
* focus
* blur
### 文档/窗口事件
* load
* resize
* scroll
* unload
## 2 事件处理
### 事件处理方法
回调函数作为参数进行传递。
```
("p").click(function(){$(this).hide()});
```
### $(document).ready()
在加载完成文档后需要执行的函数。