How do I refer to elements of elements in JavaScript?

  • 0
    Hello, here in CSS you can refer to an element of an element, like this is how you can refer to and :
    #header nav a {

    And in JavaScript, can you also refer to elements or do you have to give everything your own id / class ?
    JavaScript Anonymous, Dec 15, 2020

  • 1 Answers
  • 0
    document.querySelector or document.querySelectorAll


    const links = document.querySelectorAll(`header nav a`);

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!