I put this code at the beginning of main.js - all scripts after it stop working. And if at the end of the code - all scripts work. What is it about? Variables do not overlap. This script is working.
var newsbtn = document.querySelector('.news__to-all'); newsbtn.addEventListener('click', function (event) { event.preventDefault(); newsbtn.classList.toggle('news__to-all--show'); }); Refinement . This script only breaks scripts from other html pages. Scripts shared with him html-pages work. On another html-page there is the same script, which also lamas the scripts of all the other html-pages, except its own:
var portfBtn = document.querySelector('.portfolio__to-all'); portfBtn.addEventListener('click', function (event) { event.preventDefault(); portfBtn.classList.toggle('portfolio__to-all--show'); }); In separate files, all scripts are working.
newsbtnelementnewsbtnnot found and you are trying to hang an event on null - user3127286