jQuery not working in AJAX Loaded page

后端 未结 3 1905
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-28 10:29

I am using jQuery to load a page by AJAX using $.ajax (suppose test.html).
Its a simple HTML document with a few buttons and associated animations upon clicking them (a

相关标签:
3条回答
  • 2020-12-28 11:17

    Sounds like you need

    $('#go1').live('click', function() {});
    

    $.fn.live, as event handlers are only registered on initial dom creation, and you're repopulating the DOM and those aren't attached.

    More info @ http://docs.jquery.com/Events/live

    0 讨论(0)
  • 2020-12-28 11:20
     $("#peopleResult_list").on('click','a', function(event){
        //do you code here  
     });
    

    on event work for current dom in your page and any dom loaded by ajax in the future

    0 讨论(0)
  • 2020-12-28 11:29

    If i'm reading that right you are adding the click handlers at the beginning. These only affect current buttons. You may just need to change that to a Live event.

    0 讨论(0)
提交回复
热议问题