jQuery1第十九篇 操作CSS样式的方法
程序员文章站
2024-01-04 20:37:04
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
width: 100px;
height: 100px;
border: 1px solid #000;
}
</style>
</head>
<body>
<script src="jquery-1.10.1.min.js"></script>
<script>
$(function()
{
//设置
$("div").css("width","100px");
$("div").css("height", "100px");
$("div").css("background", "red");
//链式结构
// 2.链式设置
// 注意点: 链式操作如果大于3步, 建议分开
//$("div").css("width","100px").css("height","100px").css("background","blue");
/*$("div").css(
{
width:"100px",
height:"200px",
background:"red"
});*/
console.log($("div").css("background"));
});
</script>
<div></div>
</body>
</html>