动画图像属性左

时间:2013-05-06 07:28:07

标签: jquery html css

img的OnClick事件:

$(obj).animate({"left": "-=40px"},"slow");
$(obj).animate({"height":"600px","width":"320px"},30);

我想动画图像的宽度和高度。此外,我正在移动我的图像-40px。之后再次点击事件我想将图像恢复到原始大小和位置。我试过这个,但是左边的动画就是把图像带到非常左边而不是原来的地方。

$(obj).animate({"Right": "+=40px"},"slow");
$(obj).animate({"height":"449px","width":"249px","left":"-20px"},30);

3 个答案:

答案 0 :(得分:1)

更改:

$(obj).animate({"height":"449px","width":"249px","left":"-20px"},30);

$(obj).animate({"height":"449px","width":"249px","left":"-=20px"},30);

答案 1 :(得分:1)

哎呀......我注意到"left":"-20px"

中是额外的
$(obj).animate({"height":"449px","width":"249px","left":"-20px"},30);

删除后问题解决了。

答案 2 :(得分:0)

尝试改变:

$(obj).animate({"Right": "+=40px"},"slow");

为:

$(obj).animate({"left": "+=40px"},"slow");

因为当您使用"Right": "+=40px"时,您的obj将再次向左移动40px