Skip to content

Instantly share code, notes, and snippets.

@kevinruscoe
Last active November 7, 2021 02:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinruscoe/c70a0ff84ac431b4abde to your computer and use it in GitHub Desktop.
Save kevinruscoe/c70a0ff84ac431b4abde to your computer and use it in GitHub Desktop.
Make Bootstrap 3 navigation hover on desktop, but click on mobile
jQuery(function($){
$("ul li").click(function(event){
if( $(window).width() > 768 && event.target.className == "dropdown-toggle" ){
return false;
}
});
$(window).resize(function(){
if( $(window).width() > 768 ){
$("ul.dropdown-menu").css({display:'none'});
$("li.dropdown.open").removeClass('open');
}else{
$("ul.dropdown-menu").removeAttr('style');
}
});
})
.nav>li>a:focus {background:none}
@media (min-width: 768px) {
#nav .navbar li:hover ul.dropdown-menu {visibility: visible;display:block!important}
#nav .navbar li span {display:none}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment