# Javascript: EmbeddedFileCollection.removeElementAt Method

> Removes the embedded file at the given index.

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

---

### Description

Removes the embedded file at the given index.

### Syntax

```javascript
<void> EmbeddedFileCollection.removeElementAt(<number> index, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| index | The index in the collection of the embedded file 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 `EmbeddedFileCollection.removeElementAt` in a practical document-editing workflow. It removes the embedded file at the given index.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const embeddedFiles = mainText.embeddedFiles;
    embeddedFiles.removeElementAt(
        0,
        function() {
            console.log("remove element at completed.");
        },
        onTxError
    );
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: EmbeddedFileCollection.addTextFile Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/embeddedfilecollection/addtextfile-method/llms-full.txt)
- **Next:** [EmptyRequestCallback Function](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/emptyrequestcallback/llms-full.txt)
