A
A
Alexander92292020-12-16 03:25:19
JavaScript
Alexander9229, 2020-12-16 03:25:19

Throws an error when I run the code through webpack?

I can't figure out what's wrong.
When I run the code through webpack, the output in the browser console gives an error 5fd9534d00e8e269706188.png

Swears at this piece of code.

burger.addEventListener( `click`, () => {
        burger.classList.toggle( `burger--active` );
        headerBottom.classList.toggle( `scroll` );
    });

    const burgerElem = burger.classList.contains( `burger--active` );
    if ( !burgerElem ) {
        burger.addEventListener( `click`, () => {
            document.querySelectorAll( `.open` ).forEach( item => {
                item.classList.remove( `open` );
            });
            document.querySelectorAll( `.sub-nav` ).forEach( item => {
                item.style.display = `none`;
            });
        });
    }


Tell me, what's the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Leonid Yakovlev, 2020-12-16
@deleo547

webpack has nothing to do with it, based on the error, you are trying to hang an event handler on a variable that is null
Where does the burger variable come from?

A
Alexander9229, 2020-12-16
@Alexander9229

I understood what was the mistake, I did not transfer the html files to the collector.
Accordingly, he did not find them and gave an error

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question