I have a bunch of links with non-pre-determined id’s like so:
<a href="#" class="remove_pid" id="pid_123">Remove 123</a>
<a href="#" class="remove_pid" id="pid_234">Remove 234</a>
<a href="#" class="remove_pid" id="pid_567">Remove 567</a>
<a href="#" class="remove_pid" id="pid_890">Remove 890</a>
I have an event handler like so:
$$('.remove_pid').addEvents({
'click': removePid
});
which calls this function
function removePid(event)
{
alert('yo what is my element id???');
}
So the question is how do i get the element id in the function removePid()?
UPDATE:
@Aishwar, event.target.id seems to work in the following case, but not specifically in my case
<a href="#" class="remove_pid"><img src="/123.jpg" id="pid_123"></a>
UPDATE 2:
I thought it was inconsequential, but instead of the text “Remove 123” I actually have an image like so:
<a href="#" class="remove_pid" id="pid_123"><img src="/123.jpg"></a>
So, thanks for @Dimitra for pointing it out. I was surprised with the de-vote but am happy to say i probably deserve it.
Think I found it:
This works in FF 3.6