How to get current cursor position from multi-line textbox without selection of any data from the textbox?
Asked
Active
Viewed 479 times
0
-
http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea Is this what you want? – luiges90 Jan 07 '13 at 13:17
-
Please check this question: http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea – Hui Zheng Jan 07 '13 at 13:17
1 Answers
0
This vanilla JS DEMO should get you started.
var textArea = document.getElementsByTagName('textarea')[0];
function mouseMove(e) {
var x = e.pageX - textArea.offsetLeft,
y = e.pageY - textArea.offsetTop;
textArea.value = x + ", " + y;
}
textArea.addEventListener('mousemove', mouseMove, false);

Brian Ustas
- 62,713
- 3
- 28
- 21