JSFiddle - React, Tailwind, and code Playground
by abhitalks
HTML
<p id="p" contentEditable="false">
Hi , It's a new question in stackoverflow!
</p>
JavaScript
p = document.getElementById('p');
p.addEventListener('mouseup', setColor);
function setColor() {
p.setAttribute('contentEditable', true);
document.execCommand('styleWithCSS', false, true);
document.execCommand('foreColor', false, "#f00");
p.setAttribute('contentEditable', false);
}