/pseudo-content

Read the content of a pseudo-element

Primary LanguageJavaScript

Pseudo content

Read the content of a pseudo-element.

Install

npm install pseudo-content

Use

@media (max-width: 414px) {
  #foo:before {
    content: 'mobile';
  }
}
var foo = document.getElementById('foo');

// as second parameter you can pass the pseudo element as string - 'before' or 'after'
var fooPseudoContent = pseudoContent(foo);

console.log(fooPseudoContent.get()); // mobile
console.log(fooPseudoContent.is('mobile')); // true