doc: create JS/HTML listening event section

This commit is contained in:
Leon Xu committed 2021-08-31 15:41:09 -07:00
1 parent febeeb216c
commit ed25cb9290
1 file changed
+17 -1
+17 -1
View File
@@ -112,4 +112,20 @@ addEventListener("click", openBox);
| keydown | 按下任意键 |
| keyup | 任意键被释放 |
你可以在[这里](https://developer.mozilla.org/en-US/docs/Web/Events)找到完整的列表
你可以在[这里](https://developer.mozilla.org/en-US/docs/Web/Events)找到完整的列表
## 用JS/HTML收听事件
```
Enter Text: <input type="text" id="input
text"> <Go!>
```
![Inputs](/images/Input-Field.png)
有大量的HTML标记用于构建UI(用户界面),我们将从按钮开始
```html
<button id="my-btn">Click me!</button>
```
按钮标签内的文本呈现为按钮文本
要制作一个响应按钮(或其他UI控件):
1. 选择感兴趣的控件(如按钮)和事件(如鼠标点击)
2. 编写一个JavaScript函数在事件发生时运行
3. 将函数附加到控件上的事件