Why is this code throwing “TypeError
: Cannot read property 'style
' of null
”?
function openNav() {
document.getElementById("#sideNav").style.width = "250px";
}
function closeNav() {
document.getElementById("#sideNav").style.width = "0";
}
<div class="sidenav" id="sideNav">
<a href="javascript:void(0)" class="closenav" onclick="closeNav()">×</a>
<a href="#">Home</a>
<a href="#">Listing</a>
<a href="#">About Us</a>
<a href="#">Contact</a>
</div>
<span onclick="openNav()">OPEN</span>
<div id="main">
...
</div>