Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The selectionEnd property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position.
Note: According to the WHATWG forms spec selectionEnd property applies only to inputs of types text, search, URL, tel, and password. In modern browsers, throws an exception while setting selectionEnd property on the rest of input types. Additionally, this property returns null while accessing selectionEnd property on non-text input elements.
If selectionEnd is less than selectionStart, then both are treated as the value of selectionEnd.
A non-negative number.
| HTML # dom-textarea/input-selectionend |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Nov 5, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.