jq设置css的方法:1、设置单个样式属性,代码为【$('#test').css('background-color','red')】;2、设置多个属性你,可以传入一个对象,代码为【$('#test').css({'background】。

本教程操作环境:windows7系统、css3版,DELL G3电脑。
jq设置css的方法:
如果要设置单个样式属性可以这样
$('#test').css('background-color','red');
如果你要同时设置多个属性你,可以传入一个对象
$('#test').css({'background-color':'red','font-size':'20px'});
即属性值例如background-color,你也可以用驼峰形式backgroundColor,这时你可以不用单引号
你可以亲自试一下
<script>jquery/1.7.0/jquery.min.js"></script><script>
$(document).ready(function(){
$("button").click(function(){
$('#test').css('background-color','red');
});
});
</script><h1>jquery 设置css</h1>
<button>设置h1的css</button>
相关教程推荐:CSS视频教程
前端入门到VUE实战笔记:立即使用
在学习笔记中,你将探索 前端 的入门与实战技巧!











