ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • javascript 함수 자동호출
    JAVASCRIPT 2020. 7. 14. 13:38

    javascript 함수 자동호출

     

    1) setTimeout([Function], [Milliseconds])

     

     - 특정 시간 이 후, 단 한번만 특정 함수 또는 코드를 실행시킬 때 사용합니다.

     - 2번째 인자의 시간(Milliseconds)이 경과하면 1번째 인자의 함수를 실행합니다.

     

    2) setInterval([Function], [Milliseconds])

     

     - 특정 시간 마다 특정 함수 또는 코드를 실행시킬 때 사용합니다.

     - 2번째 인자의 시간(Milliseconds)이 지날때마다 1번째 인자의 함수를 실행합니다.

     

    3) clearInterval([Timer Id]) 

     

    - 종료

    ex)일정높이만큼 마진주기

    addTopInterval = setInterval(function() {

                       $( ".top-added").each( function(index) {

                                 

                                 $( this).css( "z-index", 10);

                                 

                                  var height  = $( this).height();

                                 

                                 $( this).css( "margin-top", $( ".header-mask").height());

                                 

                                  var maskPadding = parseInt($(".header-mask").css("padding-bottom" ), 10);

                                 $( ".header-mask").css( "margin-bottom", height + maskPadding);

                                 

                                 addTopIntervalCnt++;

                                 

                                  if(addTopIntervalCnt > 20)

                                 {

                                          clearInterval(addTopInterval);

                                 }

                       });

              

              }, 200);

     

    'JAVASCRIPT' 카테고리의 다른 글

    오브젝트 찍기  (0) 2020.07.15
    javascript json 배열 리턴 값 받기  (0) 2020.07.14
    날짜 차이 계산 공식  (0) 2020.06.11
    스크롤 위아래 구분 실행 함수  (0) 2020.06.11
    스크롤시작 종료  (0) 2020.06.11

    댓글

Designed by Tistory.