JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#">Hover 1</a>
<a id="link" href="#">Hover 2</a>
CSS
a:hover{
color:green;
}
#link:hover{
color:red;
}
JavaScript
function getStyleBySelector( selector )
{
var sheetList = document.styleSheets;
var ruleList;
var i, j;
/* look through stylesheets in reverse order that
they appear in the document */
for (i=sheetList.length-1; i >= 0; i--)
{
ruleList = sheetList[i].cssRules;
for (j=0; j<ruleList.length; j++)
{
if (ruleList[j].type == CSSRule.STYLE_RULE &&
ruleList[j].selectorText == selector)
{
return ruleList[j].style;
}
}
}
return null;
}
console.log(getStyleBySelector('a:hover').color);
console.log(getStyleBySelector('#link:hover').color);