
๐ฉ๐ปโ๐ป ์์ ์ ๋์ด๋๊ณ ์๊ฐ์ด ์์ด์ ๋ฏธ๋ค๋ ๊ฐ์๋ฅผ ๋ณต์ต ์ฐจ์์์ ๋น ๋ฅด๊ฒ ๋ฃ๋ ์ค์ด๋ค~!
์์ฃผ์์ฃผ ์ฌ์ด ์๋ฟ์ฐฝ ๋ง๋ค๊ธฐ!!!
์ฝ์ง๋ง ํ๋ผ๋ฏธํฐ ์ดํด๋ ์ค์ํ ๊ฐ๋ ์ด๋ค!! ์ด๊ฑฐ ์ดํด ๋ชปํ๋ฉด JS ์ด๋ ค์! ๐
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./css/02_AlertBox.css">
</head>
<body>
<!-- ์๋ฟ๋ฐ์ค -->
<div class="alert-box" id="alert">Hello~Javascript Alert box!!
<button class="closebutton" onclick="alertButton('none')">โ</button>
</div>
<!-- ์๋ฟ ์ด๊ธฐ ๋ฒํผ -->
<button class="clickbutton" onclick="alertButton('block')">Click</button>
<script>
// displayState๋ฅผ ํ๋ผ๋ฏธํฐ(์ธ์)๋ก ๋ฐ์์ alertBox๋ฅผ ๋ณด์ฌ์ฃผ๊ฑฐ๋ ์จ๊ฒจ์ฃผ๋ ํจ์
function alertButton(displayState){
document.getElementById('alert').style.display=displayState;
}
</script>
</body>
</html>
.alert-box {
background-color: rgb(255, 255, 137);
padding: 20px;
color: rgb(49, 152, 35);
border-radius: 5px;
display: none;
font-weight: bold;
margin-bottom: 5px;
}
.clickbutton{
cursor: pointer;
background: rgb(172, 237, 163);
border: none;
padding: 5px;
font-size: 20px;
border-radius: 10px;
}
.closebutton{
float: right;
font-size: 20px;
background: none;
border: none;
cursor: pointer;
}
