https://codepen.io/jayllopy/pen/bQgRPY
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
document.body.style.backgroundColor = "white";
}
i have this link that changes all background to white opacity 0.4 except #main with bg color red
Q: I want to change #main background to rgba(0,0,0,0.4) when sidenav is open
It will change back to red when you close it.