HTML:
<div class="chocs">Chocolate Bar <div class="id">1234</div></div>
jQuery:
$('div#groupinfo .chocs').click(function(){
alert($(this).slug.text());
});
Im trying to get the contents of the inner div (id) when the outer div is clicked.
Can this be done?
Yes it’s what jQuery is for (among other things of course). This solution uses the context parameter, it looks for elements with the class of
idinside the element that was clicked on by providingthisas the context object.DEMO