<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.alert-box {display:none;padding:20px;color:#FFF;border-radius:5px;background-color:skyblue;}
</style>
</head>
<body>
<div id="alert-box" class="alert-box">알림창이다.</div>
<button onclick="alet()">버튼이다</button>
<script>
function alet(){
document.getElementById("alert-box").style.display = "block";
}
</script>
</body>
</html>
'닫기'버튼을 만들어서 alert창을 닫기
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.alert-box {display:none;padding:20px;color:#FFF;border-radius:5px;background-color:skyblue;}
</style>
</head>
<body>
<div id="alert-box" class="alert-box">
알림창이다.
<button onclick="document.getElementById('alert-box').style.display='none';">닫기</button>
</div>
<button onclick="alet()">버튼이다</button>
<script>
function alet(){
document.getElementById("alert-box").style.display = "block";
}
</script>
</body>
</html>