2

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 to_nav is the button that should reveal the menu.

  $(window).ready(function() {
    $(window).on('resize', function(){
      var win = $(this); 

      if (win.width() >= 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();

    })

});
user3553851
  • 71
  • 2
  • 10
  • "ontap" is the onclick event. `onclick` works on both mouse and touch devices in the same way. The only diff is, there are obviously no mouse...` events like `mouseOver` on tablets / touch devices ... – Axel Amthor Apr 20 '14 at 12:48

0 Answers0