我有一个 div 开始旋转,但我不知道如何让它以一定 Angular 停止。目前所发生的一切都是在继续进行。我的问题是如何让它停在像 96 这样的 Angular 。
<script type="text/javascript">
$(function() {
var $elie = $("#super");
rotate(1);
function rotate(degree) {
$elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
$elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});
timer = setTimeout(function() {
rotate(++degree);
},2);
}
});
</script>
最佳答案
要停止在 96 度,请尝试以下操作:
if (degree < 96) {
timer = setTimeout(function() {
rotate(++degree);
}, 2);
}
关于javascript - 如何进行旋转然后停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13608598/