# Javascript: DocumentLinkCollection.getItem Method

> Gets the document link at the current text input position or the document link with the specified id.

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

---

### Description

Gets the document link at the current text input position or the document link with the specified id.

### Syntax

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

### Parameters

| Parameter | Description |
|---|---|
| callback | The callback function that receives the requested value. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| id | Optional. Specifies the document link's identifier set with the ID property. The method returns null if a link with the specified identifier does not exist. |

### Examples

The following example demonstrates `DocumentLinkCollection.getItem` in a practical document-editing workflow. It gets the document link at the current text input position or the document link with the specified id.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const documentLinks = mainText.documentLinks;
    documentLinks.getItem(
        function(result) {
            if (!result) {
                console.warn("No document link was returned.");
                return;
            }
            
            console.log("get item result:", result);
        },
        onTxError,
        25
    );
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: DocumentLinkCollection.clear Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlinkcollection/clear-method/llms-full.txt)
- **Next:** [Javascript: DocumentLinkCollection.remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentlinkcollection/remove-method/llms-full.txt)
