jQuery event.currentTarget Property


The event.currentTarget property in jQuery is the current DOM element within the event bubbling phase.

Syntax

The syntax is as follows −

event.currentTarget

Example

Let us now see an example to implement the jQuery event.currentTarget property −

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $("h1, p").click(function(event){
         alert(event.currentTarget === this);
      });
   });
</script>
</head>
<body>
<h1>World</h1>
<p>Countries list...</p>
<p>Click on any of the above element and witness a magic.</p>
</body>
</html>

Output

This will produce the following output −

Click on any of the element above and an alert box generates −

Updated on: 11-Nov-2019

152 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements