simplified, i’ve got following code:
<a id="123" href="#"><span>click</span><span>me</span></a>
when i click on ‘click’ and ‘me’ it doesnt seem to work with following jquery selector:
$("a").click...
maybe its because i click on the children? how could i write the selector so it maps to all children in ‘a’?
[updated]
The problem is that you are using the wrong tool for the job (namely the event.target property). This will return the element that the event happened on.. but not the element in the bubbling phase that handles the event… you need to use the
event.currentTarget..But in jQuery’s case this is also the same as the
thiskeyword inside the handler …ref: http://api.jquery.com/event.currentTarget/
Have a read at the Event order as explained at quirksmode. Special attention to Use of event bubbling and currentTarget
[previous answer]
Make sure that inside the
.clickmethod you use a function pointer or an anonymous function ..so
or
but not