Effects - Stop() 메서드 (애니메이션 효과 멈추기)

by 조쉬 posted Oct 16, 2014
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

 

[Stop.htm]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<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', top: '+=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', top: '-=100px' }, 2000);

            });

        }); 

    </script>

</head>

<body>

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

    <button id="stop">STOP!</button>

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

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

</body>

</html>

 

 


-------------------------------------------------------------------------------------

 


[실행결과]