Hi I have child ul and parent li which is being targeted by jquery which toggles class "shown" on click event within it. The problem I face is that for some reason when I click child ul li elements it also triggers that event. How to prevent that?
Here is my code.
<script>
$(document).ready(function() {
$('.dropdown').click(function(e) {
e.stopPropagation();
$(this).toggleClass('shown');
e.preventDefault();
})
})
</script>
<li class="dropdown"><a title="Installation" href="#">Installation <span class="caret"></span></a>
<ul role="menu" class="dropdown-menu">
<li>
<a title="Wood Floor Installation" href="">Wood Floor Installation</a></li>
<li>
<a title="Sub Floor Preparation" href="">Sub Floor Preparation</a></li>
<li>
<a title="Type of your subfloor" href="">Type of your subfloor</a></li>
<li>
<a title="Wood Floor Fitting Method" href="">Wood Floor Fitting Method</a>
</li>
</ul>
</li>