-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
28 lines (25 loc) · 1.08 KB
/
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
document.getElementById('hamburger').addEventListener('click', function() {
const navbar = document.getElementById('navbar');
navbar.classList.toggle('show'); // Toggle the 'show' class to expand/collapse
});
// Adding event listeners to each nav item
const navItems = document.querySelectorAll('#navbar ul li a');
navItems.forEach(item => {
item.addEventListener('click', function() {
const navbar = document.getElementById('navbar');
navbar.classList.remove('show'); // Hide the menu when an item is clicked
});
});
// Search function
function searchPlaces() {
const input = document.getElementById('search-input').value.toLowerCase(); // Get the search input
const places = document.querySelectorAll('.place'); // Select all places
places.forEach(place => {
const title = place.querySelector('h3').textContent.toLowerCase(); // Get place title
if (title.includes(input)) {
place.style.display = ''; // Show if it matches
} else {
place.style.display = 'none'; // Hide if it doesn't match
}
});
}