I think many of you know the sexy drop down menu that uses jQuery and CSS to style the drop down menu.
When you click on a arrow trigger, it shows the drop down menu, when you hover out it hides it.
My problem is that I can't get it to hide the drop down menu on click outside. I've searched on Internet, but unfortunately didn't find anything.
My code is :
jQuery(document).ready(function($){
$('li:has(ul)').addClass('has-children');
// Sexy Drop Down Menu
$('li.has-children').append('<span class="dropdown"></span>'); // Adding a span tag with .dropdown class to <li> with child elements
$("li.has-children .dropdown").click(function(){ // When trigger is clicked...
// Following events are applied to the subnav itself (moving subnav up and down)
$(this).parent().find("ul.sub-menu").slideDown('fast').show(); // Drop down the subnav on click
$(this).parent().hover(function(){
}, function(){
$(this).parent().find("ul.sub-menu").slideUp('slow'); // When the mouse hovers out of the subnav, move it back up
});
});
});
I tried to replace $(this).parent().hover(function(){
by $(this).parent().click(function(){
but it didn't work.
Can someone help me with this problem, please?
Thank you in advance.