03/23 5차 자바스크립트 과제

Noh Sinyoung·2023년 3월 23일
0

과제

목록 보기
5/27
<!DOCTYPE html>
<html lang="ko">
<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>Document</title>
    <style>
        .box1 {width: 500px; height: 200px; background-color: aquamarine;}
        .box2 {width: 500px; height: 200px; background-color: skyblue;}
    </style>
</head>
<body>
    <div class="box1">
        <h1>민트</h1>
    </div>

    <div class="box2">
        <h1>블루</h1>
    </div>

    


    <script>
        let 박스1
        박스1 = document.querySelector(".box1")

        박스1.addEventListener("mousedown", function () {
            박스1.style.backgroundColor="lightblue"
        })
        박스1.addEventListener("mouseup", function () {
            박스1.style.backgroundColor="aquamarine"
        })

        let 박스2
        박스2 = document.querySelector(".box2")

        박스2.addEventListener("mouseover", function () {
            박스2.style.backgroundColor="violet"
        })
        박스2.addEventListener("mouseout", function () {
            박스2.style.backgroundColor="skyblue"
        })
        

    </script>



</body>
</html>

0개의 댓글