Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
The Code is working fine in console but not when adding into file-Uncaught TypeError: Cannot read properties of null (reading 'style')

Note: Please dont delete this question before looking into - I have seen all the given solution on stackoverflow and tried all but not worked for me please see my code and and see the problem which am getting am getting problem from 3-4 days and looking for it whole day in every site but not any sol worked for me. I am working on Chat application project using socket.io and added one left side navbar on it but its button not working and giving me error but when i am adding that same code into the console its working. help me out and thanks Please Help me!!! and thanks

```
<script type="module" defer>
        let result=function(){

            let sidebar = document.querySelector(".sidebar");
            let closeBtn = document.getElementById("btn");
            let userBtn = document.querySelector(".bx-user");
            let joinRoom = document.querySelector(".joinRoom");
            let logout = document.querySelector(".logout");
    
            function menuBtnChange() {
                if(sidebar.classList.contains("open")){
                    closeBtn?.classList.replace("bx-menu", "bx-menu-alt-right");
                    logout.style.width="250px";
                    joinRoom.style.width="250px";
    
                    var x=document.querySelectorAll(".parahide");
                    for(var i=0;i<x.length;i++){
                        x[i].style.visibility="visible";
                    }
                }
                else {
                    closeBtn.classList.replace("bx-menu-alt-right","bx-menu");
                    logout.style.width="78px";
                    joinRoom.style.width="78px";
    
                    var x=document.querySelectorAll(".parahide");
                    for(var i=0;i<x.length;i++){
                        x[i].style.visibility="hidden";
                    }
                }
            }
            sidebar.classList.toggle("open");
            menuBtnChange();
    
            closeBtn.addEventListener("click", ()=>{
                sidebar.classList.toggle("open");
                menuBtnChange();
            });
    
            userBtn.addEventListener("click", ()=>{
                sidebar.classList.toggle("open");
                menuBtnChange();
            });
    
            joinRoom.addEventListener("click", ()=>{
                sidebar.classList.toggle("open");
                menuBtnChange();
            });
            logout.addEventListener("click", ()=>{
                sidebar.classList.toggle("open");
                menuBtnChange();
            });
        }
    window.onload=result;
    </script>
```
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda