Response title
This is preview!
Events bubble. So your click code may also cause click code "above" it to run. You can stop the bubbling by returning false or executing e.preventDefault() when you don’t want it to bubble.
Oh yes, I need to change that link back to simply #
Just
don't have a href
attribute
at all! Any good CSS reset would take care of the missing default
cursor style, so that is a non-issue. Then attach your JavaScript
functionality using graceful and unobtrusive best practices - which
are more maintainable as your JavaScript logic stays in JavaScript,
instead of in your markup - which is essential when you start
developing large scale JavaScript applications which require your
logic to be split up into blackboxed components and templates.
function checkSlideUp(){
if ( parent_li.hasClass('sub-menu-active') ){
jQuery('#primary-navigation ul.nav-menu > li > a').off('click').on('click', function(e){
// store parent li to variable
var parent_li = jQuery(this).parent('li');
// store current sub menu in variable
var current_submenu = jQuery('ul.sub-menu', parent_li).first();
// slide up current sub menu
current_submenu.slideUp(function(){
// remove sub-menu-active to current parent li
parent_li.removeClass('sub-menu-active');
});
});
}
}
© 2013 jQuery Foundation
Sponsored by and others.