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>
```