您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jquery中怎么修改css样式

2024/2/21 5:04:03发布22次查看
jquery中修改css样式的方法:1、使用“css(属性名,属性值)”语句修改;2、使用“css({属性名:属性值,属性名:属性值...})”语句修改;3、使用“toggleclass(“类名”)”语句修改。
本教程操作环境:windows7系统、jquery1.10.0版本、dell g3电脑。
jquery修改css样式的方法
css部分:
.div1{ width:100px; height:100px; background:#00ff00; }.div2{ width:100px; height:100px; background:#ff0000; }#btndiv{ width:100px; height:100px; border: 1px solid #ccc; margin-bottom: 10px; }
jquery代码:
<div id="btndiv" onclick="changecss()"></div> <script> $(document).ready(function (){ //第一种// $("div").css("width","100px");// $("div").css("height","100px");// $("div").css("background","cyan"); //第二种// $("div").css({// width:"100px",height:"100px",background:"red"// }); //第三种 $("div").addclass("div1"); $("div").click(function (){// $(this).addclass("div2");// $(this).removeclass("div1"); $(this).toggleclass("div2"); }); }); </script>
相关视频教程推荐:jquery教程(视频)
以上就是jquery中怎么修改css样式的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product