2017-01-26 7 views
0
<style> 
.foo { 
    color: red; <-- how to change this from jquery 
} 
</style> 

デフォルトのCSSを$()selectorなしでjqueryから変更するにはどうすればよいですか?クラス全体が要素を含むように変更されますか?jqueryはドキュメント全体のデフォルトCSSを変更します

+1

$( "foo "という)、CSS(" 色"、 "赤");これは動作しませんか? – McCuz

+0

[CSSルールセットをJavascriptから変更する]の複製があります。(http://stackoverflow.com/questions/1409225/changing-a-css-rule-set-from-javascript) – JJJ

+0

fooクラスを変更することはできませんJQueryのスタイル? – Nenroz

答えて

0

あなたはJavaScriptを使用することができます。

<head> 
    <link id="style" rel=stylesheet href="large.css"> 

</head> 

function changeStyle(){ 
     if(window.innerWidth<900){ 
      document.getElementById("style").setAttribute("href","small.css"); 

     }else if((window.innerWidth)>900 &&(window.innerWidth)<1200){ 
     document.getElementById("style").setAttribute("href","medium.css"); 
     } 
     else 
       document.getElementById("style").setAttribute("href","large.css"); 
    } 
    window.onresize=changeStyle; 
    changeStyle(); 
関連する問題