动态加载内容的动画效果 - jQuery

发布于 2024-11-27 17:00:39 字数 293 浏览 2 评论 0原文

$(function() {
 $("a").hover(
  function() {
   $(this).animate({color: "blue"}, 400);
  }, function() {
   $(this).animate({color: "white"}, 400);
 })
 $(".left").fadeOut("slow").load("created.php").fadeIn("slow");
})

我希望来自created.php 页面的链接(a's)具有悬停效果。我该怎么做呢?

$(function() {
 $("a").hover(
  function() {
   $(this).animate({color: "blue"}, 400);
  }, function() {
   $(this).animate({color: "white"}, 400);
 })
 $(".left").fadeOut("slow").load("created.php").fadeIn("slow");
})

I want the links (a's) from the created.php page to have the hover effect. How can I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唯憾梦倾城 2024-12-04 17:00:39

使用 live 绑定处理程序。这样,页面中加载的任何新“a”也将获得悬停效果。

$(function() {
     $("a").live(
     { mouseenter: function() {
             $(this).animate({color: "blue"}, 400);
          }, 
       mouseleave: function() {
            $(this).animate({color: "white"}, 400);
          }
     })
     $(".left").fadeOut("slow").load("created.php").fadeIn("slow");
});

注意:对于livehover仅需要一个处理程序。另一种方法是指定 mouseentermouseleave 处理程序。

Use live to bind handlers. That way, any new 'a' loaded in the page will also get the hover effect.

$(function() {
     $("a").live(
     { mouseenter: function() {
             $(this).animate({color: "blue"}, 400);
          }, 
       mouseleave: function() {
            $(this).animate({color: "white"}, 400);
          }
     })
     $(".left").fadeOut("slow").load("created.php").fadeIn("slow");
});

Note: With live, hover takes only one handler. Alternative is to specify mouseenter and mouseleave handlers.

戏蝶舞 2024-12-04 17:00:39

您想要使用 jquery live 方法。

 $("a").live( {mouseover: function() {
    // do something on mouseover
  },
mouseout: function() {
    // do something on mouseout
  }
});

You want to use the jquery live method.

 $("a").live( {mouseover: function() {
    // do something on mouseover
  },
mouseout: function() {
    // do something on mouseout
  }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文