# Javascript: Selection.setTextBackColor Method

> Sets the selection's background color.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 26.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: Selection.setTextBackColor Method
- **333 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/settextbackcolor-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/settextbackcolor-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/settextbackcolor-method/llms-full.txt

---

### Description

Sets the selection's background color.

### Syntax

```javascript
<void> Selection.setTextBackColor(<string> textBackColor, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| textBackColor | The selection's background color. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `Selection.setTextBackColor` in a practical document-editing workflow. It sets the selection's background color.

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

TXTextControl.selection.setTextBackColor(
    "#ffd54f",
    function() {
        console.log("set text back color completed.");
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: Selection.setText Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/settext-method/llms-full.txt)
- **Next:** [Javascript: Selection.setUnderline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setunderline-method/llms-full.txt)
