I have a jQuery plugin (which I've written) which has an option to match an optional child selector. Ie: If I have this markup:
<div class="header">
<a id="item-name">Blah</a>
<span class="some-data">Numbers and Stuff</a>
<span class="other-data">Bananas</a>
</div>
Orignally, I delegated the click event to the whole .header using:
headerDiv.on('click', function () {
But then needed to limit the click to only the anchor, so to maintain compatibility, I used the alternative syntax:
headerDiv.on('click',headerSelector, function () {
Where headerSelector
, by default is *
, but I could pass a
to limit it to just the anchor. The default *
selector I'm now using seems problematic though, sometimes clicks aren't registered. Is there a proper way to match the element itself when using the delegated event syntax?