Get ID of clicked on element in function
- by skerit
I want to get the ID of an element I click on.
I put the function in the onclick element, like this:
<a id="myid" class="first active" onclick="markActiveLink();" href="#home">Home</a>
And this is in the function:
function markActiveLink() {
alert($(this).attr("id"));
}
This doesn't work, as it says it isn't defined.
Does it really forget about the ID, do I have to type it in the onclick?