Get pseudo element, CSS content value - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window getComputedStyle

Description

Get pseudo element, CSS content value

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

#item::after {/*from   w w w  .j  a  v a 2 s .  c om*/
   content: 'test';
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
console.log(window.window.getComputedStyle(document.querySelector('#item'), ':before'));
    }

      </script> 
   </head> 
   <body> 
      <div id="item"> 
      </div>  
   </body>
</html>

Related Tutorials