JSFiddle - React, Tailwind, and code Playground

HTML

<html>
    <head>
    </head>
    <body>
        <div class="symbol">α</div>
    </body>
</html>

JavaScript

function entityForSymbolInContainer(selector) {
    var code = $(selector).text().charCodeAt(0);
    var codeHex = code.toString(16).toUpperCase();
    while (codeHex.length < 4) {
        codeHex = "0" + codeHex;
    }
    
    return "&#x" + codeHex + ";";
}

alert(entityForSymbolInContainer(".symbol"));