I've got this markup
<div contentEditable="true">
Some other editable content
<div class="field" contentEditable="false">
<span class="label">This is the label</span>
<span class="value" contentEditable="true">This is where the caret is</span>
</div>
<!-- This is where I want the Caret -->
</div>
The caret is currently in the .field
span.
I need to move it back out after the .field
in the parent contentEditable
.
How can this be accomplished via javascript (with the use of jQuery if needed) ?
It will be trying to trigger it on a keydown event when the caret is in the .value span as shown.
An update to the previous answer. http://jsfiddle.net/GLzKy/4/
placeCaretAtEnd($(this).parent().nextAll('.field').children('value'));
UPDATE
Updated answer with correct answer in comments
For moving directly after the current field, you might want to use range.setStartAfter and range.setEndAfter: http://jsfiddle.net/GLzKy/5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With