What I want to do is when I rollover .mainmenu then the .submenu fade in, but the problem is that both of them are not parent and child related, so how can I make the .submenu remain visible when I move my cursor from .mainmenu to .submenu?
http://codepen.io/vincentccw/pen/LnvJE
my html:
//////////////////////////////////////////////
<div class="mainmenu">this is text</div>
<div class="submenu">this is text2</div>
//////////////////////////////////////////////
my js:
//////////////////////////////////////////////
$( document ).ready(function() {
$(".mainmenu, .submenu").mouseenter(function(){
$(".submenu").stop(true,true).slideToggle();
console.log('slide down');
}).mouseleave(function(){
$(".submenu").stop(true,true).slideToggle();
console.log('slide up');
});
});
////////////////////////////////////////////////
http://jsfiddle.net/3bLbJ/1/