Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use Event binding on dynamically created elements in JQuery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 263
    Comment on it

    Hello Guys

    In JQuery, Events trigger a JQuery function to an event handler for the selected elements in the Html page.

    Currently we are using jQuery 1.7, So you should use jQuery.function.on() as below :

    $(staticAncestors).on(eventName, dynamicChild, function() {
    
    //Statement........
    
    });
    

    If you are using below version of JQuery 1.7 then you should use jQuery.function.live():

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

    live() function was deprecated in JQuery 1.7 in favour of on(), and live() completely removed in 1.9. The live() signature see below :

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

    Now, can be replaced with the following on() :

    $(document).on( eventName, selector, function(){
    
        //Statement........
    } );
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: