# Javascript: SectionCollection.addAtTextPosition Method

> Adds a new section at the specified text input position. The new section ends at the end position of the section containing the input position. If a new section is inserted in a paragraph or table, the paragraph or table is split into two paragraphs or tables.

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

---

### Description

Adds a new section at the specified text input position. The new section ends at the end position of the section containing the input position. If a new section is inserted in a paragraph or table, the paragraph or table is split into two paragraphs or tables.

### Syntax

```javascript
<void> SectionCollection.addAtTextPosition(<SectionBreakKind> sectionBreakKind, <number> textPosition, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| sectionBreakKind | Specifies the kind of section's break. |
| textPosition | Specifies the text position at which the section is to be inserted. |
| callback | Optional. Receives whether the section could be added. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `SectionCollection.addAtTextPosition` in a practical document-editing workflow. It adds a new section at the specified text input position. The new section ends at the end position of the section containing the input position. If a new section is inserted in a paragraph or table, the paragraph or table is split into two paragraphs or tables.

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

TXTextControl.sections.addAtTextPosition(
    TXTextControl.SectionBreakKind.BeginAtNewLine,
    -1,
    function(result) {
        if (result) {
            console.log("add at text position is available.");
        } else {
            console.warn("add at text position is not available in the current document state.");
        }
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: SectionCollection.add Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/sectioncollection/add-method/llms-full.txt)
- **Next:** [Javascript: SectionCollection.getItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/sectioncollection/getitem-method/llms-full.txt)
