Using getComputedStyle to get pseudo element from CSS - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window getComputedStyle

Description

Using getComputedStyle to get pseudo element from CSS

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 .jav a2 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