eriksv88
eriksv88

Reputation: 3526

Contenteditable div Enter issue (keyCode 13)

Enter in the Contenteditable "div" tag makes it creates a new "div" tag. How can I do so that it instead creates a "p", if you hit enter after an "img" tag?

<div id="append_id" contenteditable="true">
  This text can be edited by the user.
    <img style="height:100px;" src="myImage.jpg" />
</div>

http://jsfiddle.net/3uTmW/3/

Upvotes: 1

Views: 569

Answers (1)

Sense545
Sense545

Reputation: 494

The default paragraph can be specified in chrome by using:

document.execCommand('defaultParagraphSeparator', false, 'p')

See how to change behavior of contenteditable blocks after on enter pressed in various browsers.

Upvotes: 2

Related Questions