javascript - Getting stylesheet object from ownerNode(style tag) -


i have multiple style tags in webpage, , want manipulate cssrules in them. how can stylesheet in document.stylesheets object style element. way scanning stylesheets in document.stylesheets , match ownernode style element object. there better way this?

per http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-style-element , style element implements linkstyle interface following references can lead 1 http://dev.w3.org/csswg/cssom/#the-linkstyle-interface indicates there sheet property can access each style element (as <link rel="stylesheet">)--as long text/css, default. there can more specialized cssstylesheet interface looking (i.e., 1 cssrules).

<style>   p {color:blue;} </style> <script>    var h = document.getelementsbytagname('style')[0];   alert(h.sheet.cssrules[0].csstext); // "p { color: blue; }"  </script> 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -