I have a page with a series of links with the class "myLinkClass". These links can be in one of two DOM structures:
<div class="divClassA"> <a class="myLinkClass" ... </div>
or
<div class="divClassB"> <a class="myLinkClass" ... </div>
I am attaching a click event for class references to an event handler using jQuery:
$(document).ready(function () { $('.myLinkClass').bind('click', function (event) {
How do I know if a clickable link is inside divClassA or divClassB?
Note that although links are immediate children of the div in the examples above, this may not be the case. In addition, there can be an arbitrary number of both divClassA and divClassB (not only one at a time).
source share