닫기 버튼을 이벤트 리스너로 기능구현 하신거 보고
버튼1과 버튼2도 이벤트 리스너로 구현하고 싶어서 코드를 짜봤습니다
근데 버튼1과 버튼2를 눌러도 알림창이 안뜹니다.
코드가 잘못 되었을까요?
<body>
<div class="alert-box" id="a1">
<p id="a2">알림창임</p>
<button id="a3">닫기</button>
</div>
<button class="a4">버튼1</button>
<button class="a4">버튼2</button>
<script>
document.getElementById('a3').addEventListener('click', function(){
document.getElementById('a1').style.display = 'none'
})
document.getElementsByClassName('a4').addEventListener('click', function(){
document.getElementById('a1').style.display = 'block'
})
</script>
</body>