<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title</title>
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<style>
.box {
position: absolute;
width: 100px;
height: 100px;
background-color: blue;
top:300px;
left: 100px;
}
.box2{
background-color: red;
/*width: 100px;*/
/*height: 100px;*/
}
</style>
</head>
<body>
<div class="box"></div>
<div class="box2"></div>
</body>
<script>
console.log($(".box").css("width")
);
console.log($(".box").css("height")
);
console.log($(".box").css("background-color")
);
$(".box2").css("width",$(".box").css("width") )
$(".box2").css("height",$(".box").css("height") )
$(".box2").css("backgroundColor", $(".box").css("background-color"))
</script>
</html>
댓글 영역