# Javascript: MisspelledWordCollection.getItemAtTextPosition Method

> Gets the misspelled word of the specified kind at the specified text input position. If there is no misspelled word, the next possible word is returned. If there is no misspelled word of the specified kind between the specified input position and the end of the text, the first word of the specified kind is returned.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: MisspelledWordCollection.getItemAtTextPosition Method
- **609 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/misspelledwordcollection/getitemattextposition-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/misspelledwordcollection/getitemattextposition-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/misspelledwordcollection/getitemattextposition-method/llms-full.txt

---

### Description

Gets the misspelled word of the specified kind at the specified text input position. If there is no misspelled word, the next possible word is returned. If there is no misspelled word of the specified kind between the specified input position and the end of the text, the first word of the specified kind is returned.

### Syntax

```javascript
<void> MisspelledWordCollection.getItemAtTextPosition(<number> textPosition, <MisspelledWordKind> kind, <RequestMisspelledWordCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| textPosition | Specifies a zero-based text postion. The text positions in front of a word and behind a word belong to the word. If there is no misspelled word, the next possible word is returned. If there is no misspelled word between the specified text position and the end of the text, the first word is returned. |
| kind | Specifies the word's kind. |
| callback | Receives the misspelled word. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `MisspelledWordCollection.getItemAtTextPosition` in a practical document-editing workflow. It gets the misspelled word of the specified kind at the specified text input position. If there is no misspelled word, the next possible word is returned. If there is no misspelled word of the specified kind between the specified input position and the end of the text, the first word of the specified kind is returned.

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

function inspectItemAtTextPosition(misspelledWords) {
    misspelledWords.getItemAtTextPosition(
        -1,
        TXTextControl.MisspelledWordKind.All,
        function(result) {
            if (!result) {
                console.warn("No misspelled word was returned.");
                return;
            }
            
            console.log("get item at text position result:", result);
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [Javascript: MisspelledWordCollection.getItemAtLocation Method](https://docs.textcontrol.com/ds-server/reference/javascript/misspelledwordcollection/getitematlocation-method/llms-full.txt)
- **Next:** [Javascript: MisspelledWordCollection.ignore Method](https://docs.textcontrol.com/ds-server/reference/javascript/misspelledwordcollection/ignore-method/llms-full.txt)
