I have a problem with selecting the correct element using the .delegate method.
<div><span>Some element</span></div>
I need to select the div element even when the click event is raised through the span tag. Any ideas, how can I reach the div through the span element?
OK – i see it is not clear, so i try to explain it again:
I have a main DIV. This is the area in which all events should captured und processed. Each “click”, “keydown” and “keyup” event should be triggerd by the second level inside the main DIV. This second level is a list of other DIVs.
<div id="outline">
<div id="1"><span>Some Text <img src="could/be/picture" /></span></div>
<div id="2"><span>Some Text <ul><li>Could</li><li>Be</li><li>List</li></ul></span></div>
<div id="3"><span>Some Text <a href="#">Even a link</a></span></div>
</div>
As u can see, there could be almost every stuff inside thoses DIVs. And i need to make them all unable to trigger events. Means: Click on IMG or UL>LI or A results in an event from the underlaying DIV…(as they were not existing or disabled for events)
In your callback function,
thiswill refer to the<span>element. The<div>element you’re interested in is the parent of the<span>element, so use the jQuery.parent()function, like so: