jQuery event.delegateTarget Property

Last Updated:

jQuery event.delegateTarget Property

The jQuery event.delegateTarget property returns the element where the currently-called jQuery event handler was attached.

Note: This property is most often useful in delegated events attached by delegate() or on() method, where the event handler is attached at an ancestor of the element being processed.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery event.delegateTarget Property</h1> <div> <p>This is paragraph inside div.</p> <button>Click Me</button> </div> <div> <p>This is paragraph inside div.</p> <button>Click Me</button> </div> <script> $(document).ready(function(){ $("div").on("click", "button", function(e){ $(e.delegateTarget).css("color", "red"); }); }); </script> </body> </html>

Syntax

event.delegateTarget;

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
event.delegateTargetYesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author