$(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)具有悬停效果。我该怎么办?
答案 0 :(得分:3)
使用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");
});
注意:使用live
,hover
只需要一个处理程序。另一种方法是指定mouseenter
和mouseleave
处理程序。
答案 1 :(得分:1)
您想使用jquery live方法。
$("a").live( {mouseover: function() {
// do something on mouseover
},
mouseout: function() {
// do something on mouseout
}
});