# Javascript: DocumentTargetCollection.remove Method

> Removes the target from the collection.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: DocumentTargetCollection.remove Method
- **402 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttargetcollection/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttargetcollection/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttargetcollection/remove-method/llms-full.txt

---

### Description

Removes the target from the collection.

### Syntax

```javascript
<void> DocumentTargetCollection.remove(<DocumentTarget> documentTarget, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| documentTarget | Specifies the target to remove. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `DocumentTargetCollection.remove` in a practical document-editing workflow. It removes the target from the collection.

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

function remove(documentTarget) {
    TXTextControl.textParts.getMainText(function(mainText) {
        const documentTargets = mainText.documentTargets;
        documentTargets.remove(
            documentTarget,
            function() {
                console.log("remove completed.");
            },
            onTxError
        );
    }, onTxError);
}
```

---

## Nearby

- **Previous:** [Javascript: DocumentTargetCollection.getItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttargetcollection/getitem-method/llms-full.txt)
- **Next:** [DocumentTargetInfo Object](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documenttargetinfo/llms-full.txt)
