Skip to content

Commit

Permalink
Adjusting js
Browse files Browse the repository at this point in the history
  • Loading branch information
RamakantDadhichi committed May 3, 2024
1 parent a28df1f commit 7d29277
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ document.addEventListener("DOMContentLoaded", function() {
// Add a click event listener to each header
headers.forEach(header => {
header.addEventListener('click', function() {
// Toggle the 'active' class on the section
const section = header.parentElement;
section.classList.toggle('active');
// This finds the next sibling element (which should be the <ul> list) and toggles its display
const list = this.nextElementSibling;

// Toggle display of the list under the header
const list = section.querySelector('ul');
if (list.style.display === 'block') {
list.style.display = 'none';
} else {
Expand Down

0 comments on commit 7d29277

Please sign in to comment.