Open In App
Related Articles

jQuery event.delegateTarget Property

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

jQuery event.delegateTarget property is used to return the element where the currently-called jQuery event handler was attached. 

Syntax:

event.delegateTarget

Parameters:

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

Example 1: This example shows the use of event.delegateTarget property in jQuery.

HTML

<!DOCTYPE html>
<html>
 
<head>
    <title>
        jQuery event.delegateTarget Property
    </title>
    <script src=
    </script>
 
    <script>
        $(document).ready(function () {
            $("div").on("click", "button",
                function (event) {
                    $(event.delegateTarget).css(
                        "background-color", "green");
                });
        });
    </script>
</head>
 
<body>
    <center>
        <div>
            <h1>GeeksForGeeks</h1>
            <h2 id="geeks2">
                jQuery event.delegateTarget Property
            </h2>
            <button>Click</button>
        </div>
    </center>
</body>
 
</html>

                    

Output:

Example 2: In this example, the text size will change after clicked inside the box.

HTML

<!DOCTYPE html>
<html>
 
<head>
    <title>
        jQuery event.delegateTarget Property
    </title>
    <script src=
    </script>
 
    <script>
        $(document).ready(function () {
            $("div").on("click", function (event) {
                    $(event.delegateTarget).animate({ fontSize: "+=14px"});
                });
        });
    </script>
</head>
 
<body>
    <center>
        <div style="border: 2px solid black">
            <h1>GeeksForGeeks</h1>
            <h2 id="geeks2" style="color: green">
                A computer science portal
            </h2>
        </div>
    </center>
</body>
 
</html>

                    

Output:



Last Updated : 11 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads