Blog Content

    티스토리 뷰

    53.jQuery - stop 메서드로 다중 효과 구현 ( 08.Effects )

    반응형
    Stop() : 현재 진행중인 애니메이션효과를멈춤

    06.Stop.htm

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

        <title>애니메이션 효과 멈추기</title>

        <style type="text/css">

        div

        {

                    position:absolute; background-color:#abc; left:0px; top:50px;

                    width:60px; height:60px; margin:5px;

        }               

        </style>

     

        <script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

        <script type="text/javascript">

            $(document).ready(function() {

                //Start animation

                $("#go").click(function() {

                    $(".block").animate({ left: '+=100px' }, 2000);

                });

     

                //Stop animation when button is clicked

                $("#stop").click(function() {

                    $(".block").stop();

                });

     

                //Start animation in the opposite direction

                $("#back").click(function() {

                    $(".block").animate({ left: '-=100px' }, 2000);

                })

     

                //대각선 (연습)

                $("#Button1").click(function() {

                    $(".block").animate({ left: '-=100px', top:'-=100px' }, 2000);

                })

            });

        </script>

    </head>

     

    <body>

        <button id="go">Go</button>

        <button id="stop">Stop</button>

        <button id="back">Back</button>

        <button id="Button1">대각선</button>

        <div class="block"></div>

    </body>

    </html>



    결과확인

    [그림53-1]

    비 동기적으로 계속 실행됨


    반응형

    Comments