/
index.md
45 lines (32 loc) · 1.13 KB
/
index.md
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
---
title: "TextUpdateEvent: text property"
short-title: text
slug: Web/API/TextUpdateEvent/text
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.TextUpdateEvent.text
---
{{APIRef("EditContext API")}}{{SeeCompatTable}}
The **`TextUpdateEvent.text`** read-only property contains the text that was inserted within the updated range of a {{domxref("EditContext")}}'s `textupdate` event.
## Value
A {{jsxref("String")}} that contains the text that replaces the text contained between the {{domxref("TextUpdateEvent/updateRangeStart", "updateRangeStart")}} and {{domxref("TextUpdateEvent/updateRangeEnd", "updateRangeEnd")}} indexes.
## Examples
### Using `textupdate` to display the inserted text and location
```html
<div id="editor"></div>
```
```js
const editorEl = document.getElementById("editor");
const editContext = new EditContext();
editorEl.editContext = editContext;
editContext.addEventListener("textupdate", (e) => {
console.log(
`The user inserted the text "${e.text}" at index ${e.updateRangeStart}.`,
);
});
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}