I\'m currently using jQuery to make a div clickable and in this div I also have anchors. The problem I\'m running into is that when I click on an anchor both click events ar
ignoreParent() is a pure JavaScript solution.
It works as an intermediary layer that compares the coordinates of the mouse click with the coordinates of the child element/s. Two simple implementation steps:
1. Put the ignoreParent() code on your page.
2. Instead of the parent's original onclick="parentEvent();", write:
onclick="ignoreParent(['parentEvent()', 'child-ID']);"
You may pass IDs of any number of child elements to the function, and exclude others.
If you clicked on one of the child elements, the parent event doesn't fire. If you clicked on parent, but not on any of the child elements [provided as arguments], the parent event is fired.
ignoreParent() code on Github