blob: 87dd62fa4aaaf89f226dc603fd5a6566e6a05d6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
---
title: 'Element: select event'
slug: Web/API/Element/select_event
translation_of: Web/API/Element/select_event
---
<div>{{APIRef}}</div>
<p><strong><code>select</code></strong> 이벤트는 어떤 텍스트가 선택되었을 때 발생됩니다.</p>
<table class="properties">
<tbody>
<tr>
<th>Bubbles</th>
<td>Yes</td>
</tr>
<tr>
<th>Cancelable</th>
<td>No</td>
</tr>
<tr>
<th>Interface</th>
<td>유저 인터페이스로부터 발생된 경우 {{domxref("UIEvent")}}, 아니라면 {{domxref("Event")}}</td>
</tr>
<tr>
<th>Event handler property</th>
<td>{{domxref("GlobalEventHandlers.onselect", "onselect")}}</td>
</tr>
</tbody>
</table>
<p>The event is not available for all elements in all languages. For example, in HTML, <code>select</code> events can be dispatched only on form <code>{{HtmlElement('input/text', '<input type="text">')}}</code> and {{HtmlElement("textarea")}} elements.</p>
<h2 id="Examples">Examples</h2>
<h3 id="Selection_logger">Selection logger</h3>
<pre class="brush: html notranslate"><input value="Try selecting some text in this element.">
<p id="log"></p></pre>
<pre class="brush: js notranslate">function logSelection(event) {
const log = document.getElementById('log');
const selection = event.target.value.substring(event.target.selectionStart, event.target.selectionEnd);
log.textContent = `You selected: ${selection}`;
}
const input = document.querySelector('input');
input.addEventListener('select', logSelection);</pre>
<p>{{EmbedLiveSample("Selection_logger")}}</p>
<h3 id="onselect_equivalent">onselect equivalent</h3>
<p>You can also set up the event handler using the {{domxref("GlobalEventHandlers.onselect", "onselect")}} property:</p>
<pre class="brush: js notranslate">input.onselect = logSelection;</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('UI Events', '#event-type-select', 'select')}}</td>
<td>{{Spec2('UI Events')}}</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.Element.select_event")}}</p>
|