I have an :after pseudo element applying a font awesome icon to my table headers. I want to write a test to make sure that the icons are really there by selecting the element and testing its style. How can I get this style with jquery or plain javascript?
&:after {
content: "\f0de";
font-family: FontAwesome;
}
I've tried $('th:after')
, $('th\\:after')
, $('th::after')
and a few more things... but looking around the internet it seems like maybe it's not possible at all to test pseudo elements?
EDIT The answers in the duplicate talk about strategies around adding/editing a pseudo element. I just wanted to get the content inside it for a test. I also can't do the trick of conditionally applying a class that contains an after pseudo element because I need to hook into the existing class that the framework i'm using applies and override it. The 2nd answer to this question is how i got it to work.
var testString = window.getComputedStyle(document.querySelector('thead th'), ':after').getPropertyValue('content');