Delegate In JQuery

jQuery Event delegate() Method

When a specific function to run then the events occurs. The delegate() attaches one or more event handlers for specified elements that are children of selected elements.

It is work in both current and FUTURE elements (new element created by a script) when event handler attached using the delegate().






<!DOCTYPE html>



<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("div").delegate("button", "click", function () {







<div style="background-color:Red">

<div style ="font-family :Gigi ">

<p>This is my first paragraph.</p>


<button>Click me</button>






delegate method pic12.jpg


Note: In this output after click on the click me button paragraph <p> hide.


childSelectorRequired. It is define that one or more child element attach to the event handler
EventRequired. It is define that one or more event attached to the element.

And must be valid event, multiple event separated by space.

DataIt is define that additional data to pass along with the function.
functionRequired. It define that function to run when event occur.

You may also want to read these related articles Click here


Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now