dynamically retrieve the parent element info
Hi there,
I was wondering if I could dynamically retrieve the parent element info....
Is there anyway to retrieve the parent li's id when user clicking any links below? for example, if click the 1st "#" it returns 'myli1', 2nd '#' returns 'myli2'
something like.....
function clickHandler(event)
{
$(this).parent().attr('id');
}
Thanks
- <li id='myli1'>
<a onclick='clickHandler()' href='#'></a>
</li>
<li id='myli2'>
<a onclick='clickHandler()' href='#'></a>
</li>
<li id='myli3'>
<a onclick='clickHandler()' href='#'></a>
</li>