# Javascript: TableOfContentsCollection.getItem Method

> Gets the table of contents at the current input position or the table of contents with the specified identifier.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 29.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: TableOfContentsCollection.getItem Method
- **459 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/tableofcontentscollection/getitem-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/tableofcontentscollection/getitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/tableofcontentscollection/getitem-method/llms-full.txt

---

### Description

Gets the table of contents at the current input position or the table of contents with the specified identifier.

### Syntax

```javascript
<void> TableOfContentsCollection.getItem(<RequestTableOfContentsCallback> callback, [<ErrorCallback> errorCallback], [<number> id])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the requested table of contents or null if there is no table of contents at the current input position / with the specified identifier. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| id | Optional. The table of contents' identifier. |

### Examples

The following example demonstrates `TableOfContentsCollection.getItem` in a practical document-editing workflow. It gets the table of contents at the current input position or the table of contents with the specified identifier.

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

function inspectItem(tableOfContentss) {
    tableOfContentss.getItem(
        function(toc) {
            if (!toc) {
                console.warn("No table of contents was returned.");
                return;
            }
            
            console.log("get item result:", toc);
        },
        onTxError,
        25
    );
}
```

---

## Nearby

- **Previous:** [Javascript: TableOfContentsCollection.add Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/tableofcontentscollection/add-method/llms-full.txt)
- **Next:** [Javascript: TableOfContentsCollection.getItemByName Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/tableofcontentscollection/getitembyname-method/llms-full.txt)
