jQuery

[Effect] JQ - stop() 메서드 - 선택요소에 대해 현재 실행중인 애니메이션 중지 (= stop메서드 = 스톱메서드/스탑메서드)

목차

  1. stop() 예제 - stop()
  2. stop() 정의
  3. stop() 구문
  4. stop() 예제1 - stop(true)
  5. stop() 예제2 - stop(true,true)

 

stop() 예제 - stop()

※ stop() = stop(false,false)

※ 현재 animation만 바로 중지. 나머지는 실행.

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

  

<script> 

$(document).ready(function(){

  var hz = $("#hz");

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

    hz.animate({height: 300}, 3000);

    hz.animate({width: 300}, 3000);

    hz.animate({height: 100}, 3000);

    hz.animate({width: 100}, 3000);

  });

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

    hz.stop();

  });

});

</script>

<style>

#hz {background:#98bf21;height:100px;width:100px}

</style>


<p>

<button id="start">Start (시작)</button>

<button id="stop">Stop (현재 애니만 중지, 나머지 애니는 실행)</button>

</p>


<div id="hz"></div>

 

결과보기

 

stop() 정의

 

선택한 요소에 대해 현재 실행중인 애니메이션을 중지.

※ 매개변수 이용해 다양한 방법으로 중지 가능.

 

 

stop() 구문

 

$(selector).stop(stopAll,goToEnd)

 


[매개변수]

 

stopAll

선택. 모든 animation 중지 여부 (예제1)

  • false : 모두 중지 X. (= 현재 것만 중지) (기본값)
  • true : 모두 중지 O

 

goToEnd

선택. 현재 animation 완성 여부 (예제2)

  • false : 현재 완성 X (= 바로 중지 O)
  • true : 현재 완성 O (= 바로 중지 X)

 

 

stop() 예제1 - stop(true)

※ stop(true) = stop(true, false)

※ 모두 바로 중지.

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>  

$(document).ready(function(){

  var hz = $("#hz");

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

    hz.animate({height: 300}, 3000);

    hz.animate({width: 300}, 3000);

    hz.animate({height: 100}, 3000);

    hz.animate({width: 100}, 3000);

  });

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

    hz.stop(true);

  });

});

</script>


<style>

#hz {background:#98bf21;height:100px;width:100px}

</style>


<p>

<button id="start">Start (시작)</button>

<button id="stop">Stop (모든 애니 바로 중지)</button>

</p>


<div id="hz"></div>

 

결과보기

 

stop() 예제2 - stop(true,true)

※ 모두 바로 중지하되, 현재 것은 끝까지 완성.

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>  

$(document).ready(function(){

  var hz = $("#hz");

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

    hz.animate({height: 300}, 3000);

    hz.animate({width: 300}, 3000);

    hz.animate({height: 100}, 3000);

    hz.animate({width: 100}, 3000);

  });

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

    hz.stop(true, true);

  });

});

</script>


<style>

#hz {background:#98bf21;height:100px;width:100px}

</style>


<p>

<button id="start">Start (시작)</button>

<button id="stop">Stop (모든 애니 바로 중지, 단 현재 애니는 완성)</button>

</p>


<div id="hz"></div>

  

결과보기



분류 제목
Event JQ - event.target 속성 - 이벤트 촉발시킨 요소 반환/확인. (= event.target속성…
Event JQ - event.timeStamp 속성 - 이벤트 촉발 시간 반환/확인. (= 이벤트.타임스탬프 속성)
Event JQ - event.type 속성 - 촉발된 이벤트 (유형/타입/종류) 반환. (= 이벤트.타입 속성)
Event JQ - event.which 속성 ★ - 이벤트 일으킨 (키보드키/마우스버튼) 번호 반환/확인. (= 이벤…
Event JQ - focus() 메서드 ★★ - 포커스 될 때 이벤트 발생. (= focus 메서드 = 포커스 메서…
Event JQ - focusin() 메서드 ★★ - 해당요소(또는 자식요소) 포커스 될 때 이벤트 발생. (= foc…
Event JQ - focusout() 메서드 ★★ - 해당요소(또는 자식요소) 포커스 잃을 때 이벤트 발생. (= f…
Event JQ - keydown() 메서드 - 키보드키 내려갈 때 이벤트 발생. (= keydown메서드 = 키다운 …
Event JQ - keypress() 메서드 - 키보드키 눌렸을 때 이벤트 발생. (= keypress메서드 = 키프…
Event JQ - keyup() 메서드 - 키보드키 올라갈 때 이벤트 실행 (= keyup메서드 = 키업 메서드) ※…
Event JQ - live() 메서드 - JQ 1.9 폐기완료. on() 메서드로 대체. / 여러 이벤트 부착. …
Event JQ - load() 메서드 - JQ 3.0 폐기완료. / 요소 로드 이벤트 부착. (= load메서드 = …
Event JQ - mousemove() 메서드 - 마우스커서 이동 이벤트 부착. (= mousemove메서드 = 마우…
Event JQ - mouseout() 메서드 - 마우스커서 이탈 이벤트 부착. (= mouseout메서드 = 마우스아…
Event JQ - mouseover() 메서드 - 마우스오버이벤트 (= mouseover이벤트 = mouseover…
9/20
목록
 홈  PC버전 로그인 일본어
그누앞단언어 1
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 1
웹유틸
회원센터
홈짱닷컴 PC버전 로그인