Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda