Jquery how to bind click event on dynamically created elements?

前端 未结 2 1302
难免孤独
难免孤独 2020-12-02 02:29

I tried the below code but it is not working



        
相关标签:
2条回答
  • 2020-12-02 02:43

    You forgot the DOM ready handler

    Encase your code inside the ready handler and should work fine unless you have any errors showing up in our console.

    $(function() {
        // Your code here
    });
    
    0 讨论(0)
  • 2020-12-02 02:52

    here try this:

    <script type="text/javascript">
    $(function(){
        $('body').on('click', '.pg_previous,.pg_next', function () {
            jQuery("img.lazy").lazy({});
            alert('ddsda');
        });
    });
    </script>
    
    0 讨论(0)
提交回复
热议问题