14 lines
457 B
JavaScript
14 lines
457 B
JavaScript
document.addEventListener('click', (event) => {
|
|
// Check if the clicked item (or its parent) is the toggle button
|
|
const toggleBtn = event.target.closest('#sidebar-toggle');
|
|
|
|
if (toggleBtn) {
|
|
const sidebar = document.querySelector('.sidebar');
|
|
if (sidebar) {
|
|
sidebar.classList.toggle('sidebar--open');
|
|
} else {
|
|
console.error('Sidebar element (.sidebar) not found in the DOM.');
|
|
}
|
|
}
|
|
});
|