jQuery: delegating clicks to elements that contain other elements
- by Master Morality
So i get the gist of $.delegate and I know why it's doing what it's doing, but I'm wondering if there is a work around.
I have link elements that contain spans like so:
<a href='#'>
<span>Person Name</span>
<span>Person Info</span>
</a>
I use the following code in jQuery for event delegation:
containerElement.delegate('click','a',function(){...});
The trouble is that this only triggers when I click on white space not occupied by a span. I know it does this because delegate simply compares the event target to 'a' to check if it should fire the delegate, however I want to include the spans as well, pretty much anything inside the <a>...</a>
what do?