-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
32 lines (25 loc) · 877 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const openBtn= document.querySelector('.open-btn');
const header= document.querySelector('header');
const closeBtn= document.querySelector('.close-btn');
openBtn.addEventListener('click', ()=>{
header.classList.add('header');
closeBtn.classList.add('show-closebtn');
openBtn.classList.add('hide-open-btn');
});
closeBtn.addEventListener('click',()=>{
header.classList.remove('header');
closeBtn.classList.remove('show-closebtn');
openBtn.classList.remove('hide-open-btn');
});
const Close = ()=> {
header.classList.remove('header');
closeBtn.classList.remove('show-closebtn');
openBtn.classList.remove('hide-open-btn');
};
document.addEventListener('click',(event) => {
let isClicked= closeBtn.contains(event.target)
let isClickede= openBtn.contains(event.target)
if(!isClicked,!isClickede){
Close()
}
});