JSFiddle - React, Tailwind, and code Playground

HTML

<div contenteditable="true" id="selector" style="background-color: rgb(255,255,0);">
    Test back<span style="background-color: rgb(255,0,0);">ground</span> color.
</div>

JavaScript

$('div#selector').on('mouseup', function (){
    alert(document.queryCommandValue('backColor'));
});