Tag Archives: selection

Selecting text in input field

var input = document.getElementById("some-input"); Full selection: input.select(); Partial selection (selects second letter): input.setSelectionRange(1, 2); Putting carret in specific places: input.setSelectionRange(0, 0);//Begining of the input field input.setSelectionRange(1, 1);//After first letter To get beginning and end points of the selected text use: input.getSelectionStart input.getSelectionStart To set beginning and end points of the selected text use: input.getSelectionStart =… Read More »

Disabling text selection

-moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; in IE < 10 and Opera use unselectable="on" tag (have to be set on main and all child nodes).