I am new to javascript. I have to find length of characters before and after the caret position in contenteditable div.
Is it possible.
please Help me.......
I am new to javascript. I have to find length of characters before and after the caret position in contenteditable div.
Is it possible.
please Help me.......
Using JavaScript and jQuery:
var string = $(".contenteditable").contents().text();
var result = string.split("^");
var preceedingLength = result[0].length;
var proceedingLength = result[1].length;
alert(preceedingLength);
alert(proceedingLength);
This assumes that you have only one caret in your DIV
.