JSFiddle - React, Tailwind, and code Playground

HTML

<div id="demo"></div>

CSS

#demo {
    background-color: #ff00dd;
}

JavaScript

function hexc(colorval) {
    var parts = colorval.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    delete(parts[0]);
    for (var i = 1; i <= 3; ++i) {
        parts[i] = parseInt(parts[i]).toString(16);
        if (parts[i].length == 1) parts[i] = '0' + parts[i];
    }
    color = '#' + parts.join('');
    return color;
}


if (hexc($('#demo').css('background-color')) == '#ff00dd') {
    alert("Works!!");
}