# Javascript: TableOfContentsCollection.remove Method

> Removes a table of contents from the collection including all its text and including all DocumentTargets to where the table's links point.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 29.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TableOfContentsCollection.remove Method
- **389 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/remove-method/llms-full.txt

---

### Description

Removes a table of contents from the collection including all its text and including all DocumentTargets to where the table's links point.

### Syntax

```javascript
<void> TableOfContentsCollection.remove(<TableOfContents> element, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| element | The table of contents 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 `TableOfContentsCollection.remove` in a practical document-editing workflow. It removes a table of contents from the collection including all its text and including all DocumentTargets to where the table's links point.

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

function remove(tableOfContentss, element) {
    tableOfContentss.remove(
        element,
        function() {
            console.log("remove completed.");
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [Javascript: TableOfContentsCollection.getItemByName Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollection/getitembyname-method/llms-full.txt)
- **Next:** [TableOfContentsCollectionAddParams Object](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontentscollectionaddparams/llms-full.txt)
