Get event target tag name

Description

The following code shows how to get event target tag name.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--from w w w .  j  av a  2  s. c  o m-->
    $("#container").click(function(e) {
      alert(e.target.tagName);
      e.preventDefault();
      return false;
    });
  });
</script>
</head>
<body>
  <div id="container">
    <div>
      <p>
        This <span>is the <em>way</em> we
        </span> write <em>the</em> demo,
      </p>
    </div>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities