Fairly new to jquery. good stuff btw. however. There's something I can't seem to understand. I've got a list that I use as a navbar. Each list item was given an id.
I want to get that ID with jQuery.
the way the items are defined:
<ul id="mainList">
<li id="liFirstItem"><a class="main-link" href="#">First One</a>
<ul class="sub-links">
<li><a href="#">Sub Item 1</a></li>
<li><a href="#">Sub Item 2</a></li>
</ul>
</li>
</ul>
comming from here; Getting the ID of the element that fired an event
these are my attempts;
/*testing*/
var current = "Item: " + this.text + "\n";
/*current += "Id: " + this.id;*/
/*current += "Id: " + event.target.id;*/
var target = event.target || event.srcElement;
var id = target.id
current += "Id: " + id;
alert(current.toString());
the item always provides the correct text of the item clicked, e.g. "First One". However, the ID of this is always empty. Any ideas, what am I missing here?
Thanks a lot!