当我单击菜单项时,我得到 2 个单击事件而不是一个 - 问题出在哪里?
HTML:
<nav class="nav-collapse">
<ul class="nav">
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 1 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#1">Item</a></li>
<li><a data-toggle="tab" href="#2">Item</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 2 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#3">Item</a></li>
<li><a data-toggle="tab" href="#4">Item</a></li>
</ul>
</li>
</ul>
</nav>
JS
jQuery('nav li').on('click', 'a[data-toggle="tab"]', function(){
console.log(this);
});