Home > Web Front-end > JS Tutorial > body text

js dynamically modify css files using the cssRule_javascript technique

WBOY
Release: 2016-05-16 16:39:07
Original
1285 people have browsed it
 _.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"; 
} 
});
Copy after login

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;";
Copy after login

can only be used

cssRule.style.padding = "0px";
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template