상세 컨텐츠

본문 제목

[j쿼리] css메소드

카테고리 없음

by esoesmio 2023. 5. 24. 21:08

본문

<!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>

댓글 영역