Touch Device Hover effect

$(document).ready(function() {
/* If mobile browser, prevent click on parent nav item from redirecting to URL */
if(is_touch_device()) {
//$('.menu > li > a').attr('href' ,'#');
$('.menu li > ul').each(function (index, domEle) {
/* Method 1: Use this to modify the href on the <a> to # */
//$(domEle).prev('a').attr('href' ,'#');
/* Method 2: Use this to keep the href on the <a> intact but prevent the default action */
$(domEle).prev('a').click(function(event) {
event.preventDefault();
});
});
}
});
//check is this a mobile browser
function is_touch_device() {
return !!('ontouchstart' in window);
}
</script> 

Comments

Popular posts from this blog

Scroll After Fixed Navigation

Bootstrap CSS Customize with SCSS CSS

Best way to prevent page scrolling on drag (mobile)