【发布时间】:2017-11-02 19:21:23
【问题描述】:
尝试使用 animate() 方法在单击图像时将图像向右移动 250 像素,但失败了。
我可以使用按钮完成此操作,但是在将图像用作“按钮”时会遇到困难。
HTML
<div class="runner-animation">
<h1> Click to see how fast the runner moves! </h1>
<img src="Images/runner-clip-art.png" id="runner">
</div>
jQuery
$(document).ready(function(){
$("#runner").click(function(){
$("#runner").animate({right: '250px'});
});
任何帮助将不胜感激。
干杯
【问题讨论】:
-
图片的css位置属性是否设置为固定/相对/绝对?
-
请提供任何 jsfiddle
-
@Taplar 还没有 CSS,没有。
-
试试看。没有位置的 IIRC,上/下/左/右被忽略
-
@Taplar 是 IIRC 引导程序吗?我只想使用 jQuery。
标签: jquery html jquery-animate