小编aAl*_*mov的帖子

我希望我的动画在屏幕上水平移动,并在按下停止按钮后停止

我想在这里做几件事:

"开始"按钮启动动画,然后变为"停止"按钮.停止按钮然后停止动画,然后转回"开始"按钮,让我从停止的位置恢复.

相反,一旦按下开始或停止,动画就会消失.

当谈到这种东西时,我是新手,如果我不清楚我的意图请告诉我,我会尽力清理它.

<html>
<head>
    <meta charset="UTF-8">
    <style>
        div {left: 0px;
             bottom: 100px;}
    </style>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script> 
        $(document).ready(function(){
            move();
            Stop();
            });
        function move(){
          $("input").click(function(){
              $(this).val('Stop');
            $("div").css({left:'0%'}).animate({left:'100%'},1000, Stop);
              Stop();
          });
        }
        function Stop(){
          $("input[value='Stop']").click(function(){
              $( ":animated" ).stop(true, true, false);
              $(this).val('Start');
              move();
        });
        }
    </script> 
</head>
<body>        
    <h1 style="text-align:center"> Welcome to the test</h1>
    <input type='button' value='Start' id='oneButton'>
    <div style="height:100px;width:100px;position:absolute;">
        <img id='myRobot' src='myRobot.jpg' width="250px" height="200px"/>
    </div>    
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript jquery animation

5
推荐指数
1
解决办法
290
查看次数

标签 统计

animation ×1

javascript ×1

jquery ×1