-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (36 loc) · 1.35 KB
/
app.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const hamburger = document.getElementById('hamburger');
const overlay = document.getElementById('overlay');
hamburger.onclick = function() {
const newDiv = document.createElement('div');
const closeButton = document.createElement('button');
newDiv.classList.add('newDiv');
overlay.style.display = overlay.style.display === 'block' ? 'none' : 'block';
const links = [
{ text: 'Home', href: '#' },
{ text: 'New', href: '#' },
{ text: 'Popular', href: '#' },
{ text: 'Trending', href: '#' },
{ text: 'Categories', href: '#' }
];
links.forEach(linkData => {
const link = document.createElement('a');
link.textContent = linkData.text;
link.href = linkData.href;
link.addEventListener('mouseover', function() {
this.style.backgroundColor = 'lightgray';
});
link.addEventListener('mouseout', function() {
this.style.backgroundColor = 'transparent';
});
newDiv.appendChild(link);
});
const menu = document.getElementById('logo');
menu.appendChild(newDiv);
closeButton.textContent = 'X';
closeButton.classList.add('close-button');
closeButton.onclick = function() {
newDiv.style.display = 'none';
overlay.style.display = 'none';
};
newDiv.appendChild(closeButton);
};