2014-02-19 48 views
2

我想在平板電腦上點擊第二次點擊下拉導航鏈接。在iPad上,它已經做到了。您點擊一個標籤,子菜單div下拉。第二次點擊平板電腦時點擊下拉導航鏈接

在Android和Windows平板電腦上,會發生下拉菜單,但會同時觸發鏈接。

代碼:

jQuery("ul.menuTop > li a.students").mouseenter(function(event){ 

     event.stopImmediatePropagation() 

     jQuery("#studentsMenu").fadeIn(); 
     jQuery("#facultyMenu").hide(); 
     jQuery("#staffMenu").hide(); 
     jQuery("#alumniMenu").hide(); 
     jQuery("#aboutMenu").hide(); 
    }); 

    jQuery(".menuWrapper").mouseleave(function(){ 
     jQuery("#studentsMenu").hide(); 
    }); 

感謝

回答

0

想出了一個解決方案。

  var isMobile = navigator.userAgent.match(/(iPhone|iPad|Android|BlackBerry)/); 
     var link = jQuery("ul.menuTop > li a.students") 

     if (isMobile) { 
      jQuery(link).one("click", function (ev) { 

       ev.preventDefault(); 
      }); 

      if (jQuery("#studentsMenu").is(":visible")) { 

       jQuery(link).click(function (ev) { 

        ev.window.location = "/students"; 

       }); 

      } 
     } 

即使在userAgent匹配中使用「Windows」,Windows Tablet IE也不起作用。任何關於該修復的建議都會很棒。