Reputation: 3
I have a DIV element which has a jQuery.toggle Event. If I add a hyperlink as content of this div, a click on this hyperlink will fire the jQuery.toggle Event of the parent div. Is it possible to prevent this? The hyperlink should just open the weblink, and not fire the event.
Upvotes: 0
Views: 436
Reputation: 3873
Try with :
$("#linkInsideYourDiv").click(function(event)) {
event.stopPropagation();
// some other stuff
}
Upvotes: 2
Reputation: 9361
just call unbind on the $(this).parent when you are in the child toggle first
i.e.
$(this).parent().unbind("toggle");
Another thing you can do is call the avoid propogation method to avoid passing the toggle / click event etc back up the chain of bound listeners.
i.e.
$(this).click(function(e){
// Do your click stuff
// Prevent any further processing of the click event
e.stopPropagation();
});
Upvotes: 0