Contenteditable text editor and cursor position
Posted
by Cal S
on Stack Overflow
See other posts from Stack Overflow
or by Cal S
Published on 2010-05-30T08:30:14Z
Indexed on
2010/05/30
8:32 UTC
Read the original article
Hit count: 302
How can I (using jquery or other) insert html at the cursor/caret position of my contenteditable div:
<div contenteditable="true">Hello world</div>
For example, if the cursor/caret was between "hello" and "world" and the user then clicked a button, eg "insert image", then using javascript, something like <img src=etc etc>
would be inserted between "hello" and "world". I hope I've made this clear =S
Example code would be greatly appreciated, thanks a lot!
© Stack Overflow or respective owner