下面是
working code
。
$(document).ready(function() {
var cont_left = $("#container").position().left;
$("a img").each(function() {
var $this = $(this);
var left = $this.position().left, top = $this.position().top;
$(this).hover(function() {
// hover in
$(this).parent().parent().css("z-index", 1);
$(this).stop().animate({
height: "250",
width: "250",
left: left - 50,
top: top - 50
}, "fast");
}, function() {
// hover out
$(this).parent().parent().css("z-index", 0);
$(this).stop().animate({
height: "150",
width: "150",
left: left,
top: top
}, "fast");
});
});
$(".img").each(function(index) {
var left = (index * 160) + cont_left;
$(this).css("left", left + "px");
});
});â
所做的更改:
-
已添加
.stop()
。
-
固定动画的位置,使其强制
.stop()
(使其可以停止。)