Jquery how to bind click event on dynamically created elements?

bind, dynamic, events, jquery

Solution

here try this:

<script type="text/javascript">
$(function(){
    $('body').on('click', '.pg_previous,.pg_next', function () {
        jQuery("img.lazy").lazy({});
        alert('ddsda');
    });
});
</script>

Problem

I tried the below code but it is not working ``` <script type="text/javascript"> $(document).ready(function () { $('body').on('click', '.pg_previous,.pg_next', function () { jQuery("img.lazy").lazy({}); alert('ddsda'); }); }); </script> ``` Jquery 1.9.1

Original source