Contenteditable: How to completely remove span when pressing del or backspace

Viewed 4386

I have a contenteditable div, as shown in HTML below (caret marked by |).

I would like to remove span.label when pressing backspace or delete (i.e. the span acts as a single letter, thus to the user it looks as if Name was deleted in one single keypress)

<div contenteditable="true">
   Hallo, <span class="label">Name</span>|,
   this is a demonstration of placeholders!
   Sincerly, your
   <span class="label">Author</span>
</div>
2 Answers
Related