# Javascript: TextPart.removeSubTextPart Method

> Obsolete. This method will be removed in one of the next versions. Removes a SubTextPart from the TextPart.

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

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 26.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TextPart.removeSubTextPart Method
- **541 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/removesubtextpart-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/removesubtextpart-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/removesubtextpart-method/llms-full.txt

---

### Description

`Obsolete. This method will be removed in one of the next versions.` Removes a SubTextPart from the TextPart.

### Syntax

```javascript
<void> TextPart.removeSubTextPart(<function> callback, [<boolean> keepText], [<boolean> keepNested], [<SubTextPartInfo> subTextPart])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | A function with one parameter. Is called with a boolean value as parameter, which indicates whether the SubTextPart was succesfully removed, as soon as the information has been retrieved from the server. |
| keepText | Optional. If this parameter is set to true, the subtextpart is removed without deleting its visible text. Otherwise, the visible text is also removed. |
| keepNested | Optional. If this parameter is set to true, nested subtextparts are preserved. When the keepText parameter is set to false, this parameter is ignored. |
| subTextPart | Optional. Specifies which SubTextPart should removed from the TextPart. If this parameter is undefined then the SubTextPart at the current input position will be removed. |

### Examples

The following example demonstrates `TextPart.removeSubTextPart` in a practical document-editing workflow. Obsolete. This method will be removed in one of the next versions. Removes a SubTextPart from the TextPart.

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

function removeSubTextPart(subTextPart) {
    TXTextControl.textParts.getMainText(function(textPart) {
        textPart.removeSubTextPart(
            function() {
                console.log("remove sub text part completed.");
            },
            true,
            true,
            subTextPart
        );
    }, onTxError);
}
```

---

## Nearby

- **Previous:** [Javascript: TextPart.index Property](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/index-property/llms-full.txt)
- **Next:** [Javascript: TextPart.selection Property](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/selection-property/llms-full.txt)
