Joseph_Marzbani
Joseph_Marzbani

Reputation: 1876

How to prevent contenteditable from being passed down to children

As you can see in the following snippet, when a <div> becomes contenteditable, all the children inside is, including other <div> child elements, become contenteditable too and there seems to be no way from this to happen.

I'd like to put read-only <div> elements inside a content-editable <div>.

enter image description here

Upvotes: 0

Views: 466

Answers (2)

Pinal Sukhadiya
Pinal Sukhadiya

Reputation: 251

<div contenteditable="true">
    <p>test</p>
    <p contenteditable="false">test </p>
</div>

you can use this code

Upvotes: 0

Rishit
Rishit

Reputation: 61

Try putting content editable false on your children:

<div contenteditable="true">
    <p>You can edit me</p>
</div>

<div contenteditable="true">
    <p contenteditable="false">You can't edit me</p>
</div>

Upvotes: 1

Related Questions