jQuery | event.currentTarget Property

The event.currentTarget property in jQuery is used to return the current DOM element within the event bubbling phase.
The event.currentTarget is typically equal to “this”.

Syntax:

event.currentTarget

Parameter:



  • event: It is required parameter and this parameter comes from the event binding function.

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
      jQuery event.currentTarget Property
  </title>
    <script src=
  </script>
    
  <script>
        $(document).ready(function() {
          $("h1, h2, p").click(function(event) {
             alert(event.currentTarget === this);
            });
        });
    </script>
</head>
  
<body>
    <center>
        <h1 id="geeks1" style="color:green;">
          GeeksForGeeks
      </h1>
        <h2 id="geeks2">
          jQuery event.currentTarget Property
      </h2>
        <p>
          <b>Note:</b> Click on each HTML element.
      </p>
    </center>
</body>
  
</html>

chevron_right


Output:

Before Click:

After click on any element:

Example-2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
      jQuery event.currentTarget Property
  </title>
    
    <script src=
  </script>
   
  <script>
        $(document).ready(function() {
         $("h1, p").click(function(event) {
             alert(event.currentTarget.innerHTML);
            });
        });
    </script>
</head>
  
<body>
    <center>
        <h1 id="geeks1" 
            style="color:green;">
          GeeksForGeeks
      </h1>
        <h2 id="geeks2">
          jQuery event.currentTarget Property
      </h2>
        <p>
        <b>Note:</b> Click on each HTML element.
      </p>
    </center>
</body>
  
</html>

chevron_right


Output:

Before Click:

After click on Geeksforgeeks:



My Personal Notes arrow_drop_up

Small things always make you to think big

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.