当我点击menu-link
专门针对span
时,有效的课程没有添加或切换,如果我点击不在跨度上,那么一切正常。
$(document).on("click touchstart", ".menu-link", function(event) {
$("body").toggleClass('nav-open');
utilities.toggleContent(event);
});
utilities = function() {
var toggleContent = function(event) {
//If clicked element is an anchor and has a hash target, use it to select the toggle DIV
if (event.target.hash) {
//If it's one of the menu links
if ($(event.target).hasClass('menu-link')) {
//Close any open menus which aren't the target menu
$(".menu-content.active").not($(event.target.hash)).removeClass('active');
}
//Toggle the target menu
$(event.target.hash).toggleClass('active');
event.preventDefault();
} else {
$(this).next().toggleClass('active');
$(this).toggleClass('active');
return false;
}
},
// ...
<a href="#mainMenu" class="menu-link">
<span class="iconbar"></span>
<span class="iconbar"></span>
<span class="iconbar"></span>
</a>