jquery - Submenu on click -
i found question jquery show submenu if parent have been clicked here on stackoverflow. made jsfiddle, http://jsfiddle.net/jtaeh/4/ try out css , html. worked! in wordpress theme i'm using, they've got script overrules new custom script.
is possible overrule script in parent theme custom script in child theme in elegant manner?
or else: how can change script:
var mobile_menu = function() { if( $(window).width() < 600 && $('body').hasclass('responsive') ) { $( '#nav > ul, #nav .menu > ul' ).mobilemenu({ submenudash : '-' }); $( '#nav > ul, #nav .menu > ul' ).hide(); } } mobile_menu(); var show_dropdown = function() { var options; containerwidth = $('#header').width(); marginright = $('#nav ul.level-1 > li').css('margin-right'); submenuwidth = $(this).find('ul.sub-menu').outerwidth(); offsetmenuright = $(this).position().left + submenuwidth; leftpos = -18; if ( offsetmenuright > containerwidth ) options = { left:leftpos - ( offsetmenuright - containerwidth ) }; else options = {}; $('ul.sub-menu:not(ul.sub-menu li > ul.sub-menu), ul.children:not(ul.children li > ul.children)', this).css(options).stop(true, true).fadein(300); } var hide_dropdown = function() { $('ul.sub-menu:not(ul.sub-menu li > ul.sub-menu), ul.children:not(ul.children li > ul.children)', this).fadeout(300); } $('#nav ul > li').hover( show_dropdown, hide_dropdown );
to neat script:
$('ul li a').click(function() { $(this).parent().find('ul.sub-menu').toggle(); return false; });
?
i tried change .hover
.click
, .fadein(300)
.toggle
long shot , didn't work.
hope able answer question.
you try removing other event handlers on hover or click event (whichever appropriate before add yours:
$('ul li a').unbind('click').click(function() { $(this).parent().find('ul.sub-menu').toggle(); return false; });
Comments
Post a Comment