Home > Back-end >  How to get style tags within the style of the JSP page
How to get style tags within the style of the JSP page

Time:09-26

Existing a generic JS the function is called multiple JSP pages, but you need to call this function embedded in a web page style, style is the style of the tag, please ask is there any way in JS for style tags in your page content?

CodePudding user response:

Var style=window. GetComputedStyle? Window. GetComputedStyle (document. GetElementById (" myDiv "), null) : document. The getElementById (" myDiv "). CurrentStyle;

CodePudding user response:

Var sheet=document. StyleSheets [0];
Alert (sheet. CssText);

CodePudding user response:

Solution found, the code below
//get all the style tag
Var styleArr=document. QuerySelectorAll (" style ");
//the style of the first tag
Var tem2=styleArr [0]. InnerHTML;
  • Related