Skip to content

Instantly share code, notes, and snippets.

@jimi008
Forked from luboskmetko/nav.js
Last active May 17, 2022 08:01
Show Gist options
  • Save jimi008/f55dd12d47e7a593598459b88ceae894 to your computer and use it in GitHub Desktop.
Save jimi008/f55dd12d47e7a593598459b88ceae894 to your computer and use it in GitHub Desktop.
let el = document.querySelector('.nav');
el.className += ' is-open'; //space needed between classes
const children = Array.from(el.querySelectorAll('li')); //.map require an array
const textContents = children.map(child => child.textContent);
console.log(textContents); // should log an array of strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment