Open In App
Related Articles

jQuery event.currentTarget Property

Improve Article
Improve
Save Article
Save
Like Article
Like

The jQuery event.currentTarget property 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: In this example, we will return the true value within the event bubbling phase by clicking on any HTML element.

HTML




<!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>


Output: 

 

Example 2: In this example, we will return the same value of the element within the event bubbling phase by clicking on any HTML element.

HTML




<!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>


Output: 

 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 17 Nov, 2022
Like Article
Save Article
Similar Reads
Related Tutorials