Show and hide menu by click on button | free java script code

<button onclick="toggleText()">button</button>
<p id="Myid">Text</p>
<script>
function toggleText(){
  var x = document.getElementById("Myid");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
</script>

your menu div or nav id like Myid.

test this code on your web project and enjoy..

Related Posts

Leave a Reply

Your email address will not be published.