Reputation: 5523
I'm trying to get the ID of a <li>
item.
The item is as follows:
echo ($y<$sites-1)?"<li id='" . $sit[0] ."'>":"<li id='$sit[0]' class=\"last\">";
echo "<a href=\"javascript:selectedSite();\" onClick=\"javascript:submit(1);\" onMouseOver=\"mouseAction(1)\" onMouseOut=\"mouseAction(0)\">" . $sit[1] . "</a></li>";
and this is my function:
function selectedSite()
{
alert(/*I want the ID goes here*/);
}
Upvotes: 0
Views: 104
Reputation:
If you have to do it inline, the following will work for you:
echo "<a href=\"#\" onClick=\"selectedSite(this);submit(1);\" ...
function selectedSite(item)
{
alert(item.parentNode.id);
}
Upvotes: 6