plq
asked on
jQuery - how to assign an event to a group of controls with a common parent
Hi Folks.
I've got a html structure like this:
<div id="topdiv">
<table><tr>
<asp:placeholder id="content">
</tr>
</table>
</div>
The placeholder is populated with <td> elements and each one of those contains a structure in order of td > div > table > tr > td > div.
At that lowest level div, I want to assign a jquery click event. How could I do this in jquery code ?
I can of course lose the table elements and move to semantic html, but conceptually I just need to know how to assign an event to a group of elements, all with different ids, where they have a common parent.
thanks
I've got a html structure like this:
<div id="topdiv">
<table><tr>
<asp:placeholder id="content">
</tr>
</table>
</div>
The placeholder is populated with <td> elements and each one of those contains a structure in order of td > div > table > tr > td > div.
At that lowest level div, I want to assign a jquery click event. How could I do this in jquery code ?
I can of course lose the table elements and move to semantic html, but conceptually I just need to know how to assign an event to a group of elements, all with different ids, where they have a common parent.
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$('#topdiv table tr td div table tr td div').onclick(function(eve
target gives me the element that was clicked. So instead of adding an event to every element, I can capture it at the top level and it still gives me the lowest level element which is pretty cool..