What is wrong with this code? How is it correct?

  • 0
    let accounts = document.querySelector('#accounts');
    accounts.addEventListener("click", workAccounts , false)
    function workAccounts() {
        let licenzia = document.querySelector('#licenzia')
        licenzia.style.display = 'none'
        let accountsblock = document.querySelector('#accountsblock')
        accountsblock.style.display = 'grid'

    When uploading to the site, it says "TypeError: accounts is null"
    JavaScript Keira Mata, Oct 2, 2019

  • 1 Answers
  • 0
    So at the time of execution

    let accounts = document.querySelector('#accounts');

    there is no # accounts element on the page
    Oliver Vasquez

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