Javascript .on()和AJAX的问题

Javascript .on()和AJAX的问题,javascript,jquery,ajax,Javascript,Jquery,Ajax,我的标题中有这些行 $( document ).ready(function() { $(".thumb").hide(); $(".thumb").first().show(); $(".text" ).mouseenter(function() { $(this).prev(".thumb").show(); }).mouseleave(function() { $(this).prev(".thumb").hide(); }); });

我的标题中有这些行

$( document ).ready(function() {

   $(".thumb").hide();
   $(".thumb").first().show();
   $(".text" ).mouseenter(function() {
   $(this).prev(".thumb").show();
      }).mouseleave(function() {
   $(this).prev(".thumb").hide();
   });

});
它们在页面加载时工作得很好,但当我用AJAX加载新的HTML内容时,这些行就被忽略了

在我之前的问题中,有个温和的人告诉我使用.on() 可以但是如何将这个.on()应用于上面的代码

我知道这对你们大多数人来说都是一个愚蠢的问题,但我是一个绝对的初学者,而且
如果有人能给我一些有用的建议,我将不胜感激。

您的代码应该是这样的(可以修改)


谢谢,这个很好用。
  $(document).ready(function() {
     $(".thumb").hide();
     $(".thumb").first().show();
     $(document).on('mouseenter',".text",function(){ $(this).prev(".thumb").show(); })
     $(document).on('mouseleave',".text",function(){ $(this).prev(".thumb").hide(); })
  });