js 动态修改css文件用到了cssRule
作者:bea
_.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 &
_.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";
}
});
循环用的underscore,在使用cssRule不能直接使用下面的代码,否则不会生效
cssRule.style=" left: 0;position:';right: 0; top: 0px;z-index: 1031;";
只能使用
cssRule.style.padding = "0px";
猜你喜欢
您可能感兴趣的文章:
- js中实现多态采用和继承类似的方法
- js中运算符&& 和 || 的使用记录
- 字段太多jquey快速清空表单内容方法
- jQuery .tmpl() 用法示例介绍
- jQuery控制TR显示隐藏的三种常用方法
- jQuery截取指定长度字符串代码
- jquery实现的下拉和收缩效果示例
- 简单的jquery左侧导航栏和页面选中效果
- 使用jQuery设置disabled属性与移除disabled属性
- JS使用for循环遍历Table的所有单元格内容
- Javascript 绘制 sin 曲线过程附图
- json字符串之间的相互转换示例代码
- js设置控件的隐藏与显示的两种方法
- JS不能跨域借助jquery获取IP地址的方法
- jQuery添加/改变/移除CSS类及判断是否已经存在CSS
- jQuery CSS()方法改变现有的CSS样式
- JavaScript检查某个function是否是原生代码的方法
- 使用时间戳解决ie缓存的问题
- js中使用replace方法完成某个字符的转换