<style>
.foo {
color: red; <-- how to change this from jquery
}
</style>
如何在没有$()选择器的情况下从jquery更改默认css?那么整个元素包含的类会改变吗?
答案 0 :(得分: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();