JSFiddle - React, Tailwind, and code Playground

HTML

<input id="trigger" type="button" value="test"/>
<p class="x" >some text</p>
<p>another text</p>

CSS

.x{color:red;}

JavaScript

$('#trigger').click(function(){
    if($('p.x').css("color") == 'rgb(255, 0, 0)'){
       var text= $('p.x').text();
       alert(text);
    }
});