How to make clickable anchor in contentEditable div?

Infinity picture Infinity · Aug 21, 2012 · Viewed 12.3k times · Source

I have following code:

<div contentEditable="true">
    Blah blah <a href="http://google.com">Google</a> Blah blah
</div>

Fiddle

Is there a way to make this a clickable, not editable, without moving anchor outside that div?

Answer

Forty-Two picture Forty-Two · Aug 21, 2012

Just wrap the link in another div, like so:

<div contentEditable="true">

    <div contentEditable="false">
            Bla bla <a href="http://google.com">Google</a> Bla bla
    </div>
</div>​