I tried the following code on Chrome:
document.execCommand("insertBrOnReturn", false, true);
Wether I set the last parameter to true or false, the behaviour doesn't change: on return, new <div>
elements will be added.
Must have missed something... any ideas?
insertBrOnReturn
is a Mozilla specific command, Chrome doesn't support it. You can test that with:jsFiddle here, it alert
true
in Firefox, butfalse
in Chrome.If you want to insert
<br>
only, try:Also, check this: Prevent contenteditable adding <div> on ENTER - Chrome