I\'m finding tons of good, crossbrowser anwers on how to SET the cursor or caret index position in a contentEditable
element, but none on how to GET or find its
$("#editable").on('keydown keyup mousedown mouseup',function(e){
if($(window.getSelection().anchorNode).is($(this))){
$('#position').html('0')
}else{
$('#position').html(window.getSelection().anchorOffset);
}
});
body{
padding:40px;
}
#editable{
height:50px;
width:400px;
border:1px solid #000;
}
#editable p{
margin:0;
padding:0;
}
move the cursor to see position
position :