I wanna do the following for the menu in mobile devices: On a single click, the children items should drop down. But on double clicks,it should take me directly to its page. Eg. About item has children and I also a link that takes me to the about page. If I click on it, the sub-item should show up as a block levels elements. But if I double click, it should take me directly to its link ( in this case, to the About page).
I tried this:
$(document).ready(function (){
var clicks = 0;
$( "ul#primary > li.menu-item-has-children" ).click(function( e ) {
clicks++;
if(clicks === 1)
{
e.preventDeafult();
$("ul#primary > li.menu-item-has-children ul.sub-menu").css("display","block");
}
else if(clicks > 1) {
window.location($(this).attr("href"));
}
});
});
Apparently, the else statement is being executed. But when I click for the first time, the sub-menu does not show.
I also tried using slideToggle() instead of the css property but it does not work. Unfortunately the site is still on a test domain and password protected so I can not paste the link here. Hope you can help.