How to bind event on dynamically created elements

Solution for Event binding on dynamically created elements, jQuery how to bind click event on dynamically created element, Bind events to dynamically created elements using jQuery, jQuery:Binding events to dynamic DOM elements or Dynamic Event Binding Demo in jQuery is simple jQuery on() function.

jQuery live()

Before jQuery version 1.7 bind event on dynamically created elements handled by live(). From jQuery version 1.7 live() was deprecated and removed in jQuery version 1.9. jQuery live() replaced with jQuery on().

$(selector).live( eventName, function(){} );

jQuery on()

$(document).on(eventName, selector, function(){});
$('body').on(eventName, selector, function(){});

$('body').on('click blur', '#myelement', function(){
    alert('Event fired');

Event Delegation

jQuery live(), on() is related to Event Delegation. Event delegation allows us to attach a single event listener, to a parent element, that will fire for all descendants matching a selector, whether those descendants exist now or are added in the future.

For demo and more information on Event Delegation click here.