Make an h2 tag unremovable in a contenteditable section

Posted by Travis on Stack Overflow See other posts from Stack Overflow or by Travis
Published on 2010-03-17T21:29:18Z Indexed on 2010/03/17 21:31 UTC
Read the original article Hit count: 526

Filed under:
|
|

is it possible to make a section within a contenteditable element permanent, so that a user cannot remove it?

I have an h2 tag in a contentEditable div. I don't want the user to edit the h2 tag, so I set contentEditable=false, but the user can still select and remove it, which I want to disallow.

So, for ex:

<div contentEditable="true">
  <h2 contentEditable="false">My h2 tag</h2>
  This is a div you can edit. But you can't edit or remove the h2 tag.
</div>

© Stack Overflow or respective owner

Related posts about contenteditable

Related posts about html