πŸ“ƒλ…Έλ§ˆλ“œμ½”λ” Vanilla JS λ©”λͺ¨1

μ†Œμ—°Β·2021λ…„ 6μ›” 21일
0

vanillaJS

λͺ©λ‘ 보기
2/8

HTML

<!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">
    <link rel="stylesheet" href="style.css">
    <title>Momentum</title>
</head>
<body>
    <div class="hello">
        <h1>Grab me1</h1>
    </div>
    <div class="hello">
        <h1>Click me!</h1>
    </div>
    <div class="hello">
        <h1>Grab me3</h1>
    </div>
    
    <script src="app.js"></script>
</body>
</html>

CSS

@charset "UTF-8";

body{
    background-color: beige;
}

JS

const a = document.querySelector(".hello:nth-child(2)")
console.log(a.innerText);

function click(){
    a.style.color = "blue";
}

function over(){
    a.style.color = "red";
}

function title(){
    console.log("title was clicked!");
}

a.addEventListener("mouseover", click);
a.addEventListener("mouseout", over);
a.addEventListener("click", title);
profile
코린이πŸ€ͺ

0개의 λŒ“κΈ€