4

I have insert a line break within TinyMCE

tinyMCE.execCommand('mceInsertContent',false, "<br/>");

However the cursor currently stays where it was before.. which makes sense, however I would like code which moves the cursor the end of the html I just inserted?

bananabreadbob
  • 369
  • 2
  • 10
  • 26

1 Answers1

6

Adding a space after the <br/> will reposition the cursor:

So change:

tinyMCE.execCommand('mceInsertContent',false, "<br/>");

to

tinyMCE.execCommand('mceInsertContent',false, "<br/> ");

Example: http://codepen.io/anon/pen/PbKQpJ (demo links above editor)

K Scandrett
  • 16,390
  • 4
  • 40
  • 65