Advertisement
gregwhitworth

CSSOM and Style Attr

Feb 19th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <title>Testing CSSOM</title>
  6.   <style>
  7.     .test {
  8.         outline: varpx solid somethingcrazy;
  9.         background: superlongwordthatisnotvalid;
  10.     }
  11.   </style>
  12. </head>
  13. <body>
  14.   <div class="test" style="background: superlongwordthatisnotvalid">Testing</div>
  15.   <script>
  16.     (function () {
  17.    
  18.         var el = document.querySelector( "div" );
  19.         var storedInStyle = el.getAttribute( "style" );
  20.         var bgCSSOM = document.styleSheets[0].cssRules[0].style.background;
  21.         var outlineCSSOM = document.styleSheets[0].cssRules[0].style.outline;
  22.  
  23.         console.log("Background in CSSOM: " + bgCSSOM);
  24.         console.log("Outline in CSSOM: " + outlineCSSOM);
  25.         console.log("Style Attr: " + storedInStyle);
  26.        
  27.     }());
  28.   </script>
  29. </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement