# Javascript: TextPartCollection.getItem Method

> Gets the text part with the input focus.

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

---

### Description

Gets the text part with the input focus.

### Syntax

```javascript
<void> TextPartCollection.getItem(<RequestTextPartCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the requested textpart object. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `TextPartCollection.getItem` in a practical document-editing workflow. It gets the text part with the input focus.

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

TXTextControl.textParts.getItem(
    function(textPart) {
        if (!textPart) {
            console.warn("No formatted text was returned.");
            return;
        }
        
        console.log("get item result:", textPart);
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: TextPartCollection.activate Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textpartcollection/activate-method/llms-full.txt)
- **Next:** [Javascript: TextPartCollection.getMainText Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/textpartcollection/getmaintext-method/llms-full.txt)
