In cases where the specified selection length would cause the selection to end between a carriage return and a  A user can select a range by clicking on the left mouse button and then moving the cursor position by dragging the mouse. Get current cursor position in a textbox, id="Javascript_example" name="one" type="text" value="Javascript example" onclick="textbox()"> function isMouseInBox(e) { var textbox = document.​getElementById('textbox'); // Box position & sizes var boxX = textbox. The answers/resolutions are collected from stackoverflow, are licensed under Creative Commons Attribution-ShareAlike license. In order to set caret cursor position in content editable elements like div tag is carried over by JavaScript Range interface. selectionStart, selectionStart; element.selectionStart = value;. The caret-color property in CSS changes the color of the cursor (caret) in inputs, texareas, or really any element that is editable, like:. How To Get Position Cursor in TextBox Or TextArea, JQuery coding :