Skip to content Skip to sidebar Skip to footer

Bind Events To Mutliple Appended Data

I am using jQuery to post some data to a PHP script that processes it and then appends the echoed data. Now there is also some jQuery script among the data echoed it all works fine

Solution 1:

Since you're dynamically creating the elements, you have to use event delegation using .on()

$(document).on('click','.delete',function() {
    $(this).hide()
});

Also, it is better for performance if you replace document with a static parent selector to .delete

Post a Comment for "Bind Events To Mutliple Appended Data"