# Javascript: TextPart.selection Property

> Obsolete. This property will be removed in one of the next versions. The getter returns an object of type Selection. The setter changes the selection to a given start position and a given length using an object of type SelectionBounds.

> **Note:** This is deprecated and should not be used in new work.

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

---

### Description

`Obsolete. This property will be removed in one of the next versions.` The getter returns an object of type Selection. The setter changes the selection to a given start position and a given length using an object of type [SelectionBounds](https://docs.textcontrol.com/ds-server/reference/javascript/selectionbounds/llms-full.txt).

### Syntax

```javascript
<Selection> TextPart.selection
```

### Examples

The following example demonstrates `TextPart.selection` in a practical document-editing workflow. Obsolete. This property will be removed in one of the next versions. The getter returns an object of type Selection. The setter changes the selection to a given start position and a given length using an object of type SelectionBounds.

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

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

---

## Nearby

- **Previous:** [Javascript: TextPart.removeSubTextPart Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/removesubtextpart-method/llms-full.txt)
- **Next:** [Javascript: TextPart.type Property](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/type-property/llms-full.txt)
