# Javascript: FormattingStyle.apply Method

> Applies all set attributes of the style to the current document.

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

---

### Description

Applies all set attributes of the style to the current document.

### Syntax

```javascript
<void> FormattingStyle.apply([<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `FormattingStyle.apply` in a practical document-editing workflow. Applies all set attributes of the style to the current document.

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

function apply(formattingStyle) {
    formattingStyle.apply(
        function() {
            console.log("apply completed.");
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [FormattingStyle Object](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/formattingstyle/llms-full.txt)
- **Next:** [Javascript: FormattingStyle.getAutoBaseline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/formattingstyle/getautobaseline-method/llms-full.txt)
