Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

open/close sidebar changing buttons

 function w3_open() {
 document.getElementById("mySidebar").style.display = "block";
 document.getElementById("w3-button").style.display = "none"
 document.getElementById("w3-buttondos").style.display ="inline-block"

 }

 function w3_close() {
 document.getElementById("mySidebar").style.display = "none";
 document.getElementById("w3-buttondos ").style.display = "none"
 document.getElementById("w3-button").style.display ="inline-block"
 }
<button class="w3-button w3-teal" onclick="w3_open()">&#9776;</button>
     <button class="w3-buttondos w3-teal" onclick="w3_close()">&#10006;</button>

it says me -> Uncaught TypeError: document.getElementById(…) is null

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

document.getElementById does not target a node by its class="" but by its id=""

<button id="w3-button" class="w3-button w3-teal" onclick="w3_open()">&#9776;</button>

To target an element by its class you can use document.querySelector

document.querySelector(".w3-button")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading