You forgot to hide your submenu in the mouseleave function. Just add $(this).find(".submenu").hide();
to an existing handler:
$(".category").mouseleave(function() { $(this).find(".submenu").hide(); $(this).css("background-color", "#eee"); $(this).css("border", "1px solid grey"); $(this).css("border-bottom", "none"); $(this).css("width", "180px"); $(".category:last").css("border-bottom", "1px solid grey"); });
source share