Skip to content

Commit 94c83e9

Browse files
committed
fixes
1 parent 5c56e0d commit 94c83e9

File tree

1 file changed

+19
-7
lines changed
  • 2-ui/4-forms-controls/3-events-change-input

1 file changed

+19
-7
lines changed

Diff for: 2-ui/4-forms-controls/3-events-change-input/article.md

+19-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Let's cover various events that accompany data updates.
44

55
## Event: change
66

7-
The [change](http://www.w3.org/TR/html5/forms.html#event-input-change) event triggers when the element has finished changing.
7+
The `change` event triggers when the element has finished changing.
88

99
For text inputs that means that the event occurs when it loses focus.
1010

@@ -15,11 +15,21 @@ For instance, while we are typing in the text field below -- there's no event. B
1515
<input type="button" value="Button">
1616
```
1717

18-
For other elements: `select`, `input type=checkbox/radio` it triggers right after the selection changes.
18+
For other elements: `select`, `input type=checkbox/radio` it triggers right after the selection changes:
19+
20+
```html autorun height=40 run
21+
<select onchange="alert(this.value)">
22+
<option value="">Select something</option>
23+
<option value="1">Option 1</option>
24+
<option value="2">Option 2</option>
25+
<option value="3">Option 3</option>
26+
</select>
27+
```
28+
1929

2030
## Event: input
2131

22-
The `input` event triggers every time a value is modified.
32+
The `input` event triggers every time after a value is modified.
2333

2434
Unlike keyboard events, it triggers on any value change, even those that does not involve keyboard actions: pasting with a mouse or using speech recognition to dictate the text.
2535

@@ -50,7 +60,7 @@ These events occur on cutting/copying/pasting a value.
5060
5161
They belong to [ClipboardEvent](https://www.w3.org/TR/clipboard-apis/#clipboard-event-interfaces) class and provide access to the data that is copied/pasted.
5262
53-
We also can use `event.preventDefault()` to abort the action.
63+
We also can use `event.preventDefault()` to abort the action, then nothing gets copied/pasted.
5464
5565
For instance, the code below prevents all such events and shows what we are trying to cut/copy/paste:
5666
@@ -64,11 +74,13 @@ For instance, the code below prevents all such events and shows what we are tryi
6474
</script>
6575
```
6676

67-
Technically, we can copy/paste everything. For instance, we can copy a file in the OS file manager, and paste it.
77+
Please note, that it's possible to copy/paste not just text, but everything. For instance, we can copy a file in the OS file manager, and paste it.
78+
79+
There's a list of methods [in the specification](https://www.w3.org/TR/clipboard-apis/#dfn-datatransfer) that can work with different data types including files, read/write to the clipboard.
6880

69-
There's a list of methods [in the specification](https://www.w3.org/TR/clipboard-apis/#dfn-datatransfer) to work with different data types, read/write to the clipboard.
81+
But please note that clipboard is a "global" OS-level thing. Most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety.
7082

71-
But please note that clipboard is a "global" OS-level thing. Most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety. Also it is forbidden to create "custom" clipboard events in all browsers except Firefox.
83+
Also it's forbidden to generate "custom" clipboard events with `dispatchEvent` in all browsers except Firefox.
7284

7385
## Summary
7486

0 commit comments

Comments
 (0)