【发布时间】:2011-09-22 16:07:09
【问题描述】:
我试图让我的图像在鼠标悬停(悬停)时进行动画处理,但由于某种原因它根本不起作用。
$(document).ready(function(){
$(function() {
$('img.caption').hover(function(){
$(this).find('img').animate({top:'182px'},{queue:false,duration:500});
}, function(){
$(this).find('img').animate({top:'0px'},{queue:false,duration:500});
});
});
});
和相邻的html
<div class="imagediv"><img class="caption" src="images/gallery/placeholder.jpg" alt="This is test" title="" /></div>
我还有另一个悬停链接到标题类,这可能是冲突吗?当我将鼠标悬停在图像上时,什么也没有发生:/
这会干扰其他代码吗?
$(document).ready(function(){
$(".caption").hover(
function () {
$("#gallerydescription").html( $(this).attr("alt"));
},
function () {
$("#gallerydescription").html("");
}
);
});
【问题讨论】:
-
为什么会有
$(document).ready(function() {和$(function() {?它们是等价的,你只需要一个
标签: jquery image jquery-animate