0

When an element is clicked, I load new elements with the same class into the page.

    $(document).ready(function(){
        $(".myClass").click(function(){
            --load_new_elements with class="myClass"--
        });
    });

Is it possible to make the script working for new loaded elements as well - or must I each time load a new script for the newly created elements?

crumpi
  • 21
  • 4

1 Answers1

0

So you want to use a delegate event handler. See below.

$("div#container").on('click', 'button.alert', function() { alert(1); });

This will bind the click to new events as well.

Rivers
  • 2,102
  • 1
  • 16
  • 27