jQuery 抄袭笔记(3) : 通过JS更改CSS(1)
06 Oct 2011好多的站都有一个”隐藏/显示侧边栏”或者改变主题颜色的按钮,其实很好实现滴~
这节很简单,通过JS增加一个class,然后用css改变字体颜色。
Html+JS+CSS:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
</span>
<meta http-equiv=“Content-Type” content=“text/html; charset=gb2312″ />
</span>Hello Lazynight!</title>
<script type=“text/javascript” src=“jquery-1.1.3.pack.js”></script>
<script type=“text/javascript”>
$(document).ready(function(){
$(“#css1″).addClass(“css2″);
});
</script>
.css2{color:red;}
</head>
</span>
<div id=“css1″>
通过JS添加一个class"css2",就是这么简单!
</div>
</body>
</html> </div> 下载源码 解压密码 lazynight.me 转载请注明:[于哲的博客][1] » [jQuery 抄袭笔记(3) : 通过JS更改CSS(1)][2] [1]: http://lazynight.me [2]: http://lazynight.me/373.html
<html xmlns=“http://www.w3.org/1999/xhtml”>
</span>
<meta http-equiv=“Content-Type” content=“text/html; charset=gb2312″ />
<script type=“text/javascript” src=“jquery-1.1.3.pack.js”></script>
<script type=“text/javascript”>
$(document).ready(function(){
$(“#css1″).addClass(“css2″);
});
</script>
.css2{color:red;}
</head>
</span>
<div id=“css1″>
通过JS添加一个class"css2",就是这么简单!
</div>
</body>
</html> </div> 下载源码 解压密码 lazynight.me 转载请注明:[于哲的博客][1] » [jQuery 抄袭笔记(3) : 通过JS更改CSS(1)][2] [1]: http://lazynight.me [2]: http://lazynight.me/373.html