API Docs for: 3.11.0-git
Show:

Selection Class

Normalizes text selection functionality across browsers.

Constructor

Selection

()

Item Index

Methods

range

(
  • [index=0]
)
Range

Returns the Range instance at the specified index, or the first range in this selection if no index is specified. If no ranges are selected, returns null.

Parameters:

  • [index=0] Number optional

    Range index.

Returns:

Range:

Range instance at the specified index, or the first range in this selection if no index is specified. If no ranges are selected, returns null.

ranges

() Range[]

Returns an array containing all the ranges in this selection.

Returns:

Range[]:

Array containing all the ranges in this selection.

select

(
  • range
  • [options]
)
chainable

Selects the specified range.

By default, this will result in only this range being selected. If options.multi is truthy, then the range will be added to the current selection without first unselecting any other selected ranges.

Parameters:

  • range Range

    Range to select.

  • [options] Object optional

    Options.

    • [multi=false] Boolean optional

      If true, the specified range will be added to the current list of selected ranges instead of replacing the current selection.

toString

() String

Returns a string representation of the combined text content of all the ranges in this selection.

Returns:

String:

String representation of the combined text content of all the ranges in this selection.

unselect

(
  • [range]
)
chainable

Removes the specified range from this selection, or unselects all ranges if no range is specified.

Parameters:

  • [range] Range optional

    Range to unselect.