jquery .live on load event

前端 未结 9 1304
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 01:06

I need a way to use the jquery .live() function to act on elements that are loaded via ajax.

For instance a div is loaded via ajax .load()<

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 01:39

    For example (expanding on my comment above) this is from the jQuery docs..

    $.ajax({
      url: 'ajax/test.html',
      success: function(data) {
        $('#mydiv').html(data);
        alert('Load was performed.');
      }
    });
    

    replace the alert with the code you want to run/action you wish to perform

提交回复
热议问题