210411 JavaScript jQuery setInterval 연습

ITisIT210·2021년 4월 12일
0

jQuery

목록 보기
42/142
post-thumbnail
<!DOCTYPE html>
<html lang="en">
    <head>
            <meta charset="UTF-8">
            <title>Document</title>
    </head>
    <boby>
        <button>Stop!</button>

        <script src="js/jquery-3.6.0.min.js"></script> 
        <script src="js/jquery-ui.min.js"></script> 
        
        <script>
            var a = 0;
            var autoPlay = setInterval(function() {
                console.log(a);
                a++;
            }, 500);
            // setInterval(함수, 시간) : 특정 함수를 지정한 시간마다 반복
            // setTimeout() : 지정한 시간 이후에 특정 함수를 실행
            // clearInterval(변수) : setInterval()을 취소

            $("button").on("click", function() {
                // setInterval(function() {
                //     console.log(a);
                //     a++;
                // }, 500);
                // setTimeout(function() {

                // })
                clearInterval(autoPlay);
            });
        </script>
    </boby>
    </html>
profile
Engineering is the closest thing to magic that exists in the world.

0개의 댓글