Search code examples
javascriptjqueryhtmlcursorcontenteditable

Javascript/jQuery set cursor in editable DIV


Had a look at a few methods of moving the cursor around and cant seem to come up with a elegant / working way.

I basicly want to call a line of code to do the following psuedo code.

  1. Get length of text in editable div
  2. Set cursor to last letter

e.g.

this is sample text|

cursor set to where | is

How simple is this?

JsFiddle:http://jsfiddle.net/v8agZ/5/

Thanks


Solution

  • I think you can use jCaret plugin

    A Demo , Not mine