JSFiddle - React, Tailwind, and code Playground
HTML
<div id="editable" contenteditable="true">This is a div with contenteditable=true</div>
<a id="link" href="#">Click this link to blur the contenteditable element</a>
<div id="log">
</div>
CSS
#editable, #link, #log {
margin: 30px;
padding: 10px;
}
#editable, #link {
font-size: 2em;
}
#editable {
background: gray;
color: white;
}
JavaScript
// Log all click, focus and blur events on the contenteditable element
$('#editable').on('click focus blur', function(e) {
$('#log').append(e.type + ' event<br>');
});
// Force the contenteditable element to blur when the link is clicked
$('#link').on('click', function(e) {
$('#editable').blur();
e.preventDefault();
});
// Focus the contenteditable element
$('#editable').focus();