需要将对象动画化到顶部并使其返回
Need to animate an object to top and make it go back
我需要我的飞机飞上跑道(这是地图),然后点击回来。到目前为止,它只会上升。 任何与java script/html/jquery相关的内容。请提出简单的建议。泰^^ 这是我当前的代码:
<div class="Map"><div id="MovingPlane1"></div></div>
.JS:
<script type="text/javascript">
$(document).ready(function(){
$("#MovingPlane1").click(function(){
$("#MovingPlane1").animate({bottom:"250px"},"slow");
});
});
<script>
jsBin demo
为您的两个平面提供一个类.plane
并使用以下代码:
$(".plane").click(function(){
$(this).animate({bottom:250},800,function(){
$(this).animate({bottom:0},800);
});
});
在动画回调中,重做初始位置。
尝试:
$(this).animate({bottom:"250px"},"slow",function(){
$(this).animate({bottom:"0px"},"slow");
});
如果您需要飞机在第二次单击时返回,请使用以下命令:
var plane1up = false;
$(document).ready(function(){
$("#MovingPlane1").click(function(){
$("#MovingPlane1").animate({bottom:(plane1up==true ? "0px" : "250px")},"slow");
});
});
相关文章:
- 输入类型按钮返回历史记录并返回顶部
- 滚动前返回顶部
- 辅助功能键盘专用选项卡到z索引“;返回顶部”;
- 如何在滚动到底部后在页脚上方设置“返回顶部”
- 返回顶部按钮在加载时出现
- 包含动态内容的较长页面上的返回顶部链接
- 需要将对象动画化到顶部并使其返回
- “返回顶部”按钮仅在窗口滚动时可见(但移动设备不起作用)
- Javascript - window.getComputedStyle 返回 “auto” 作为元素顶部和左侧属性
- 单击“返回顶部”按钮(滚动顶部)多次发布
- 如何使用react js添加平滑滚动返回顶部按钮
- 返回“;顶部“;具有javascript的标记的属性
- 点击图片后返回顶部
- 当用户不进行交互时,如何使图像返回到屏幕顶部
- responseText正在返回我的php文件的顶部
- 即使单击返回顶部按钮,也会弹出关闭
- JQUERY”;点击滚动“;单击任何内容时都会返回顶部
- 在使用母版页和Ajax提交表单后返回到页面顶部
- 在Firefox和Opera中使用图像映射时,顶部偏移量返回不正确
- 设置时避免返回页面顶部position to fixed with jQuery