aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/element/select_event/index.md
blob: eb359f0d7ecac24f87b07c250ef11545147e8ba2 (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
---
title: select
slug: Web/API/Element/select_event
translation_of: Web/API/Element/select_event
---
L'évènement `select` est déclenché quand du texte est sélectionné. L'évènement peut ne pas être disponible pour tous les éléments dans tous les langages. Par exemple, en [HTML5](http://www.w3.org/TR/DOM-Level-3-Events/#references-HTML5), les évènements select ne peuvent être envoyés que sur des éléments `input` de formulaire et `textarea`.

## Info générale

- Spécification
  - : [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-select)
- Interface
  - : UIEvent si généré depuis une interface utilisateur, Event sinon.
- Remonte
  - : Oui
- Annulable
  - : Non
- Cible
  - : Élément
- Action par Défault
  - : Aucune

## Propriétés

| Property                              | Type                                             | Description                                                                                   |
| ------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------- |
| `target` {{readonlyInline}}     | [`EventTarget`](/en-US/docs/Web/API/EventTarget) | The event target (the topmost target in the DOM tree).                                        |
| `type` {{readonlyInline}}       | [`DOMString`](/en-US/docs/Web/API/DOMString)     | The type of event.                                                                            |
| `bubbles` {{readonlyInline}}    | [`Boolean`](/en-US/docs/Web/API/Boolean)         | Whether the event normally bubbles or not.                                                    |
| `cancelable` {{readonlyInline}} | [`Boolean`](/en-US/docs/Web/API/Boolean)         | Whether the event is cancellable or not.                                                      |
| `view` {{readonlyInline}}       | [`WindowProxy`](/en-US/docs/Web/API/WindowProxy) | [`document.defaultView`](/en-US/docs/Web/API/Document/defaultView) (`window` of the document) |
| `detail` {{readonlyInline}}     | `long` (`float`)                                 | 0.                                                                                            |

## Exemple

```html
<input id="test" type="text" value="Sélectionnez-moi !" />
<script>
  var elem = document.getElementById('test');
  elem.addEventListener('select', function() {
    alert('La sélection a changé !');
  }, false);
</script>
```