0

Placed my code here http://jsfiddle.net/50zb8xxo/8/

Want to detect cursor position before execution of javascript

Found example here https://stackoverflow.com/a/6847328/2118559 but code is long. Trying to do the same with some short code.

Found some short examples, but none works

Tried these

<div id='editable' style="width: 180px; height:70px; border: 1px solid #ccc;" contenteditable></div>


var editable = document.getElementById('editable'), selection, range;
var editable = window.getSelection().getRangeAt(0);
var editable = window.getSelection();
alert ( editable );

In all cases alert see blank popup

Here https://stackoverflow.com/a/3976125/2118559 some code, but also not short...

Community
  • 1
  • 1
Andris
  • 1,434
  • 1
  • 19
  • 34

1 Answers1

0

Try this. It will help.

var ins = document.getElementById('editable').selectionStart;

Its working

Ganesh Gaxy
  • 657
  • 5
  • 11