T
Terry
Hi folks.
I was wondering if I have a bunch of anchors that all have the same
function which is being called when a user click on them can I obtain
the index of the anchor calling the function through the dom? I was
thinking about using document.getElementsByTagName('a') somehow.
My code would look something like this:
<a href="" onclick="showContent()">Breakfast</a>
<a href="" onclick="showContent()">Lunch</a>
<a href="" onclick="showContent()">Dinner</a>
I have a feeling it can be done using a loop within showContent but I
was hoping that it can be done without having to loop.
Thanks,
Terry
I was wondering if I have a bunch of anchors that all have the same
function which is being called when a user click on them can I obtain
the index of the anchor calling the function through the dom? I was
thinking about using document.getElementsByTagName('a') somehow.
My code would look something like this:
<a href="" onclick="showContent()">Breakfast</a>
<a href="" onclick="showContent()">Lunch</a>
<a href="" onclick="showContent()">Dinner</a>
I have a feeling it can be done using a loop within showContent but I
was hoping that it can be done without having to loop.
Thanks,
Terry