Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery how to bind click event on dynamically created elements?

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

like image 993
MonsterMMORPG Avatar asked Jul 09 '13 21:07

MonsterMMORPG


1 Answers

here try this:

<script type="text/javascript">
$(function(){
    $('body').on('click', '.pg_previous,.pg_next', function () {
        jQuery("img.lazy").lazy({});
        alert('ddsda');
    });
});
</script>
like image 145
RicardoE Avatar answered Oct 03 '22 12:10

RicardoE