【发布时间】:2018-01-14 01:25:48
【问题描述】:
我正在尝试通过 jQuery 处理动画,但我遇到了一个问题,即 div 框只能单击 2 次。任何形式的帮助表示赞赏。 这是我的代码:
$(document).ready(function() {
$("#one").click(function() {
$("div").animate({
top: '250px'
});
});
$("#sec").click(function() {
$("div").animate({
bottom: '250px'
});
});
$("#thi").click(function() {
$("div").animate({
right: '250px'
});
});
$("#for").click(function() {
$("div").animate({
left: '250px'
});
});
});
.box {
background: grey;
height: 20px;
width: 20px;
position: absolute;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="one">DOWN</button>
<button id="sec">TOP</button>
<button id="thi">LEFT</button>
<button id="for">RIGHT</button>
<br><br>
<div class="box">
</div>
【问题讨论】:
-
一个准备好的函数就足够了:)
-
我已经这样做了,但问题仍然存在。
-
这里是更新的 jsfiddle jsfiddle.net/mcutmbcy/10
标签: javascript jquery html css jquery-animate