Search code examples
javascripthtmlhyperlinkonclickgetid3

Onclick does not pass Id or Element


I'm trying to pass the element or even the Id of the element over to my javascript function. I can not find my error. I did test to make sure the Onclick does go inside my JS function.

This is the Onclick html link:

<div class="true">
  <a class="tflink" id="q2t" href="#" onclick="check(this)">True</a>
</div>

This is my JS function:

function check(e)
{
    alert(e.Id);
}

Solution

  • it's supposed to be e.id not e.Id

    so it should look like this:

    function check(e)
    { alert(e.id);}