My anchor tag is not working
here is my code :
$('.tree div').click(function(){
var o = $(this);
o.children('div').slideToggle();
o.filter(".parent").toggleClass("expand");
return false;
});
my html code is :
<div class="tree">
<div class="parent">
Parent
<div class="parent">
Parent 1
<div>
<a href="http://google.com">Childe 2.1</a>
</div>
<div>
Childe 2.2
</div>
</div>
<div class="parent">
Parent 2
<div>
one 3.1
</div>
<div>
one 3.2
</div>
</div>
</div>
<div class="parent">
Parent
<div class="parent">
parent 1
<div>
Childe 2.1
</div>
<div>
Childe 2.2
</div>
</div>
<div class="parent">
parent 2
<div>
Childe 2.1
</div>
<div>
Childe 2.2
</div>
</div>
</div>
</div>
but when i click on Childe 2.1 it doesn’t open google.com
Please help me.
Thanks
I think this is what you want. The
e.stopPropagation()is what I added.Note I also added
eas an argument to the functionfunction(e).Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.