I have a contenteditable div, like so:
<div id="test" contentEditable="true" style="width: 600px; height:300px;">Lorem ipsum dolor sit amet</div>
for which I use the following code:
<input type="button" value="Click me" onclick="alert(window.getSelection().focusOffset.toString());"></button>
Clicking on the button when I move the caret around in the div, returns to me the actual position (offset) of the caret within the div.
The problem is when I replace the contenteditable div with an input type=text or password control, and keep the contenteditable property=true, and click on the button, I always get a zero. Why is this?
Thanks for looking.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…