Home  >  Article  >  Web Front-end  >  js dynamically modify css files using the cssRule_javascript technique

js dynamically modify css files using the cssRule_javascript technique

WBOY
WBOYOriginal
2016-05-16 16:39:071278browse
 _.find(document.styleSheets[4].cssRules,function(cssRule){ 
if(cssRule.selectorText && cssRule.selectorText.indexOf(".navbar-fixed-top2")>-1){ 
cssRule.style.position=""; 
cssRule.style.top = "0px"; 
} 
if(cssRule.selectorText && cssRule.selectorText.indexOf("#pageIndi_content, #page1_l1_content, #page_appList") >-1){ 
cssRule.style.padding = "0px"; 
} 
if(cssRule.selectorText && cssRule.selectorText.indexOf("#page1_index_content") >-1){ 
cssRule.style.padding = "0px"; 
} 
});

The underscore used for looping cannot be used directly when using cssRule, otherwise it will not take effect

cssRule.style=" left: 0;position:'';right: 0; top: 0px;z-index: 1031;";

can only be used

cssRule.style.padding = "0px";
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn