2020/JQuery

jquery animation stop

꽃꽂이하는개발자 2020. 3. 6. 11:33
반응형
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script>
      $(document).ready(function() {
        $("#start").click(function() {
          $("div").animate({ left: "100px" }, 1000);
          $("div").animate({ fontSize: "3em" }, 5000);
        });
        $("#stop").click(function() {
          $("div").stop();
        });
        $("#stop2").click(function() {
          $("div").stop(true);
        });
        $("#stop3").click(function() {
          $("div").stop(true, true);
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <button id="start">Start</button>
    <button id="stop">Stop</button>
    <button id="stop2">Stop all</button>
    <button id="stop3">Stop but finish</button>
    <div
      style="background:#98bf21; height:100px; width:200px; position:absolute;"
    >
      HELLO
    </div>
  </body>
</html>
반응형