e01.org

TextUpdateEvent: text property

EditContext API

EditContext API

The **`TextUpdateEvent.text`** read-only property contains the text that was inserted within the updated range of an EditContext's `textupdate` event.

## Value

A String that contains the text that replaces the text contained between the updateRangeStart and 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

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"TextUpdateEvent: text property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/TextUpdateEvent/text

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·