title: Javascript: onclick to ontap for mobile
body: <p>I'm working on a responsive website that has a clickable drop down menu for mobile size screens. It works on small laptop screens on a mouse click but I'm having trouble figuring out how to have it react in the same way to a touch for mobile. Either plain Javascript or Jquery methods welcome. The class <strong>to_nav</strong> is the button that should reveal the menu. </p>
  
  <pre><code>  $(window).ready(function() {
      $(window).on('resize', function(){
        var win = $(this); 
  
        if (win.width() &gt;= 600) { document.getElementById('menu').style.display='inline'; }
      });
  });
  
  displaynav= function () {
      var nav = document.getElementById("menu");
      if (nav.style.display == 'none'){
          nav.style.display = "block";
      }
      else { nav.style.display = 'none';}
  }
  
  $(document).on("ready",function(){
  
      $('.to_nav').click(function(){
         displaynav();
  
      })
  
  });
  </code></pre>