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: Use the HTML5 contenteditable Attribute You can set the HTML5 contenteditable attribute with the value true (i.e. contentEditable="true" ) to make an element editable in HTML, such as <div> or <p> element.
Definition and Usage The contenteditable attribute specifies whether the content of an element is editable or not.
The contenteditable global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.
Just set contentEditable="false" . See this answer.
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>
Make the link itself uneditable (works at least on HTML5):
<a contenteditable="false" href="http....... >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With