jQuery之操作样式的css方法

注意点都在代码里

 1     <style>
 2         div {
 3              200px;
 4             height: 200px;
 5             background-color: pink;
 6         }
 7     </style>
 8     <div></div>
 9     <script>
10         // 操作样式之css方法
11         $(function () {
12             console.log($("div").css("width"));
13             // $("div").css("width", "300px");
14             // $("div").css("width", 300);
15             // $("div").css(height, "300px"); 属性名一定要加引号
16             $("div").css({
17                  400,
18                 height: 400,
19                 backgroundColor: "red"
20                 // 如果是复合属性则必须采取驼峰命名法,如果值不是数字,则需要加引号
21             })
22         })
23     </script>
原文地址:https://www.cnblogs.com/jianguo221/p/11956188.html