# Javascript: FormattedText.selection Property

> Gets the current selection.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Property
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: FormattedText.selection Property
- **213 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/selection-property/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/selection-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/selection-property/llms-full.txt

---

### Description

Gets the current selection.

### Syntax

```javascript
<Selection> FormattedText.selection
```

### Examples

The following example demonstrates `FormattedText.selection` in a practical document-editing workflow. It gets the current selection.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(formattedText) {
    const selection = formattedText.selection;
    console.log("selection:", selection);
}, onTxError);
```

### Limitations

Read Only.

---

## Nearby

- **Previous:** [Javascript: FormattedText.paragraphs Property](https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/paragraphs-property/llms-full.txt)
- **Next:** [Javascript: FormattedText.subTextParts Property](https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/subtextparts-property/llms-full.txt)
