我需要我的飞机在跑道上飞行(这是地图)然后再点击。到目前为止它只会上升。 任何与java脚本/ html / jquery相关的东西。请简单的建议。 ty ^^ 这是我目前的代码::
<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>
答案 0 :(得分:1)
为您的飞机提供班级.plane
并使用此代码:
$(".plane").click(function(){
$(this).animate({bottom:250},800,function(){
$(this).animate({bottom:0},800);
});
});
在动画回调中你重做初始位置。
答案 1 :(得分:0)
尝试:
$(this).animate({bottom:"250px"},"slow",function(){
$(this).animate({bottom:"0px"},"slow");
});
答案 2 :(得分:0)
如果您需要飞机在第二次点击时返回,请使用以下内容:
var plane1up = false;
$(document).ready(function(){
$("#MovingPlane1").click(function(){
$("#MovingPlane1").animate({bottom:(plane1up==true ? "0px" : "250px")},"slow");
});
});