Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save slavapas/e735899e4242756b241bae47ef4b8610 to your computer and use it in GitHub Desktop.
Save slavapas/e735899e4242756b241bae47ef4b8610 to your computer and use it in GitHub Desktop.
show-hide dropdown menu on hover-mouseout using jquery
variant 1
------------
$(document).ready(function () {
$("#moretab").mouseenter(function(){
$("#categories").show();
});
$("#categories, #moretab").mouseleave(function(){
$("#categories").hide();
});
});
--------------------------------------------
variant 2
------------
//html
<ul>
<li id = "menu"> <a href ="#"> Settings </a>
<ul id = "sub_menu">
<li> <a href ="#"> page 1</a></li>
<li> <a href ="#"> page 2</a></li>
</ul>
</li>
<li>SomeLink</li>
<li>SomeLink 2</li>
</ul>
//Javascript
$("#menu").hover(function() {
$("#sub_menu").show();
}, function() {
$("#sub_menu").hide();
});
---------------------------------------
variant 3
------------
$(document).ready(function(){
$('.dropdown').hover(
function(){
$(this).children('.sub-menu').slideDown('fast');
},
function () {
$(this).children('.sub-menu').slideUp('fast');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment