js 動態修改css檔案用到了cssRule,csscssrule

來源:互聯網
上載者:User

js 動態修改css檔案用到了cssRule,csscssrule

 _.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動態更改 css

$('li').each(function(){ if ( $(this).attr('value') == 'mm'){ $(this).addClass('yourClass') }})
 
怎才可以更改js檔案裡的css

如果你是不是想可以修改的js??
<script src="demo.jsp"></script>
<script src="demo.asp"></script>
<script src="demo.aspx"></script>
<script src="demo.php"></script>
相應的檔案裡面用相應代碼處理就可以
裡面的格式
respose 輸出 和js 檔案裡面的格式一樣就可以
不生效 就為空白就可以了!
<script src="demo.jsp?參數=值"></script>
可以用參數的形式做處理
靜態頁面話就沒辦法修改了
只能 直接修改js檔案
補充: 可以啊!!給<span id="spa"><script src="a.js"></script> </span>
//外面加個span
<script>
document.all.spa.innerHTML="";
</script>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.