# Selection Object

> Describes and handles the attributes of a text selection. Each of the properties of this class returns the property's default value if the selection does not contain a common value.

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

---

### Description

Describes and handles the attributes of a text selection. Each of the properties of this class returns the property's default value if the selection does not contain a common value.

### Syntax

```javascript
Selection
```

### Examples

The following example demonstrates `Selection` in a practical document-editing workflow. Describes and handles the attributes of a text selection. Each of the properties of this class returns the property's default value if the selection does not contain a common value.

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

TXTextControl.selection.getText(
    function(result) {
        console.log("get text result:", result);
    },
    onTxError
);
```

---

## In This Section

- [Javascript: Selection.Attribute Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/attribute-enumeration/llms-full.txt): Determines a certain selection attribute.
- [Javascript: Selection.changeCapitalization Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/changecapitalization-method/llms-full.txt): Changes the capitalization of all selected characters depending on the 'capitalizationParameter' parameter.
- [Javascript: Selection.changeDirection Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/changedirection-method/llms-full.txt): Changes the writing direction of all selected paragraphs. When the direction of a paragraph is changed, this paragraph's alignment is toggled from left to right or from right to left. The alignment of centered and justified paragraphs is not changed. Left and right tabulators are also toggled.
- [Javascript: Selection.decreaseIndent Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/decreaseindent-method/llms-full.txt): Decreases the left indent of all paragraphs contained in the current text selection. If no text is selected, this method decreases the left indent at the text input position. Left indent positions are defined through the paragraphs' tab positions and the indents of the paragraphs in front and behind the paragraph with the text input position.
- [Javascript: Selection.getAutoBaseline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getautobaseline-method/llms-full.txt): Gets values specifying automatic sub- or superscripted text. When using automatic sub- and superscript the font is scaled and moved above or below the baseline with values defined through the font itself. Automatic sub- and superscript can be combined with a user-defined baseline which can be set with the Baseline property.
- [Javascript: Selection.getBaseline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getbaseline-method/llms-full.txt): Gets the baseline alignment, in twips, of the selected text. Takes a callback function as a parameter which is called with the baseline alignment, in twips, of the selected text. Positive values moves the baseline to superscript, negative values move the baseline to subscript.
- [Javascript: Selection.getBold Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getbold-method/llms-full.txt): Gets the bold attribute of the selected text.
- [Javascript: Selection.getCapitals Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getcapitals-method/llms-full.txt): Gets values specifying wheather lowercase letters are displayed with capital letters. Lowercase letters are displayed either with capital letters of the same size or with capital letters which have a smaller size. The smaller size is either the size of the lowercase 'x' (petite caps) or the size of the lowercase 'x' + 10% (small caps).
- [Javascript: Selection.getCharacterScaling Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getcharacterscaling-method/llms-full.txt): Gets or sets the style's character scaling, in percent of the average character width.
- [Javascript: Selection.getCharacterSpacing Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getcharacterspacing-method/llms-full.txt): Gets the style's character spacing value, in twips. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.
- [Javascript: Selection.getCulture Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getculture-method/llms-full.txt): Gets the culture as a languagecode2-country / regioncode2 string value. Takes a callback function as a parameter which is called with a languagecode2-country / regioncode2 string ("de-DE", "en-US" or "en", for example) as a parameter upon receiving the selection information from the server.
- [Javascript: Selection.getFontName Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getfontname-method/llms-full.txt): Gets the font name of the selected text.
- [Javascript: Selection.getFontSize Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getfontsize-method/llms-full.txt): Gets the font's size, in points, of the selected text.
- [Javascript: Selection.getForeColor Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getforecolor-method/llms-full.txt): Gets the color used to display the selected text.
- [Javascript: Selection.getFormattingStyle Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getformattingstyle-method/llms-full.txt): Gets the formatting style of the selected text.
- [Javascript: Selection.getItalic Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getitalic-method/llms-full.txt): Gets the italic attribute of the selected text.
- [Javascript: Selection.getLength Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getlength-method/llms-full.txt): Gets the number of selected characters.
- [Javascript: Selection.getStart Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getstart-method/llms-full.txt): Gets the starting point of selected text.
- [Javascript: Selection.getStrikeout Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getstrikeout-method/llms-full.txt): Gets the strikeout attribute of the selected text.
- [Javascript: Selection.getText Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/gettext-method/llms-full.txt): Gets the currently selected text.
- [Javascript: Selection.getTextBackColor Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/gettextbackcolor-method/llms-full.txt): Gets the background color of the selected text.
- [Javascript: Selection.getUnderline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/getunderline-method/llms-full.txt): Gets the underlining styles of the selected text.
- [Javascript: Selection.growFont Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/growfont-method/llms-full.txt): Increases the font size of each font contained in the current text selection.If no text is selected, this method increases the font size at the text input position.
- [Javascript: Selection.increaseIndent Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/increaseindent-method/llms-full.txt): Increases the left indent of all paragraphs contained in the current text selection. If no text is selected, this method increases the left indent at the text input position. Left indent positions are defined through the paragraphs' tab positions and the indents of the paragraphs in front and behind the paragraph with the text input position.
- [Javascript: Selection.isCommonListFormatValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/iscommonlistformatvalueselected-method/llms-full.txt): Informs about whether an attribute from the ListFormat.Attribute enumeration has the same value for the complete selection.
- [Javascript: Selection.isCommonPageBorderValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/iscommonpagebordervalueselected-method/llms-full.txt): Informs about whether an attribute from the PageBorder.Attribute enumeration has the same value for the complete selection.
- [Javascript: Selection.isCommonPageMarginsValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/iscommonpagemarginsvalueselected-method/llms-full.txt): Informs about whether an attribute from the PageMargins.Attribute enumeration has the same value for the complete selection.
- [Javascript: Selection.isCommonPageSizeValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/iscommonpagesizevalueselected-method/llms-full.txt): Informs about whether an attribute from the PageSize.Attribute enumeration has the same value for the complete selection.
- [Javascript: Selection.isCommonPargraphFormatValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/iscommonpargraphformatvalueselected-method/llms-full.txt): Informs about whether an attribute from the ParagraphFormat.Attribute enumeration has the same value for the complete selection.
- [Javascript: Selection.isCommonSectionFormatValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/iscommonsectionformatvalueselected-method/llms-full.txt): Informs about whether an attribute from the SectionFormat.Attribute enumeration has the same value for the complete selection.
- [Javascript: Selection.isCommonSelectionValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/iscommonselectionvalueselected-method/llms-full.txt): Informs about whether an attribute from the Selection.Attribute enumeration has the same value for the complete selection.
- [Javascript: Selection.listFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/listformat-property/llms-full.txt): Gets a bulleted or numbered list and / or its formatting attributes for the selected text.
- [Javascript: Selection.load Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/load-method/llms-full.txt): Loads text in a certain format into the current selection.
- [Javascript: Selection.paragraphFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/paragraphformat-property/llms-full.txt): Gets the formatting attributes of the selected paragraphs.
- [Javascript: Selection.removeFormatting Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/removeformatting-method/llms-full.txt): Resets all character based formatting attributes of the selected text to its default values. If nothing or more than one paragraph is selected, all paragraph based formatting attributes are also reset.
- [Javascript: Selection.removeInlineStyles Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/removeinlinestyles-method/llms-full.txt): Removes all character based styles of the selected text so that all attributes are reset to the attributes of the paragraph style.
- [Javascript: Selection.save Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/save-method/llms-full.txt): Saves the current selection in a certain format and sends the result back asynchronously by calling a given callback function.
- [Javascript: Selection.sectionFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/sectionformat-property/llms-full.txt): Gets page settings such as margins, size and orientation for the selected text.
- [Javascript: Selection.setAutoBaseline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setautobaseline-method/llms-full.txt): Sets values specifying automatic sub- or superscripted text. When using automatic sub- and superscript the font is scaled and moved above or below the baseline with values defined through the font itself. Automatic sub- and superscript can be combined with a user-defined baseline which can be set with the Baseline property.
- [Javascript: Selection.setBaseline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setbaseline-method/llms-full.txt): Sets the baseline alignment, in twips, of the selected text.
- [Javascript: Selection.setBold Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setbold-method/llms-full.txt): Sets the bold attribute of the selected text.
- [Javascript: Selection.setBounds Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setbounds-method/llms-full.txt): Obsolete. This method will be removed in one of the next versions. Sets the selection's start position and length.
- [Javascript: Selection.setCapitals Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setcapitals-method/llms-full.txt): Sets values specifying wheather lowercase letters are displayed with capital letters. Lowercase letters are displayed either with capital letters of the same size or with capital letters which have a smaller size. The smaller size is either the size of the lowercase 'x' (petite caps) or the size of the lowercase 'x' + 10% (small caps).
- [Javascript: Selection.setCharacterScaling Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setcharacterscaling-method/llms-full.txt): Sets or sets the style's character scaling, in percent of the average character width.
- [Javascript: Selection.setCharacterSpacing Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setcharacterspacing-method/llms-full.txt): Sets the style's character spacing value, in twips. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.
- [Javascript: Selection.setCulture Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setculture-method/llms-full.txt): Sets the culture as a languagecode2-country / regioncode2 string value.
- [Javascript: Selection.setFontName Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setfontname-method/llms-full.txt): Sets the font's name of the selected text.
- [Javascript: Selection.setFontSize Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setfontsize-method/llms-full.txt): Sets the font's size, in points, of the selected text.
- [Javascript: Selection.setForeColor Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setforecolor-method/llms-full.txt): Sets the selection's foreground color.
- [Javascript: Selection.setFormattingStyle Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setformattingstyle-method/llms-full.txt): Sets the formatting style of the selected text.
- [Javascript: Selection.setItalic Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setitalic-method/llms-full.txt): Sets the italic attribute of the selected text.
- [Javascript: Selection.setLength Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setlength-method/llms-full.txt): Sets the number of selected characters.
- [Javascript: Selection.setStart Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setstart-method/llms-full.txt): Sets the starting point of selected text.
- [Javascript: Selection.setStrikeout Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setstrikeout-method/llms-full.txt): Sets the strikeout attribute of the selected text.
- [Javascript: Selection.setText Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/settext-method/llms-full.txt): Sets the currently selected text.
- [Javascript: Selection.setTextBackColor Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/settextbackcolor-method/llms-full.txt): Sets the selection's background color.
- [Javascript: Selection.setUnderline Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/setunderline-method/llms-full.txt): Sets the underlining styles for the selected text.
- [Javascript: Selection.shrinkFont Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/shrinkfont-method/llms-full.txt): Decreases the font size of each font contained in the current text selection. If no text is selected, this method decreases the font size at the text input position.

---

## Nearby

- **Previous:** [Javascript: SectionFormat.setRestartPageNumbering Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/sectionformat/setrestartpagenumbering-method/llms-full.txt)
- **Next:** [Javascript: Selection.Attribute Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/selection/attribute-enumeration/llms-full.txt)
