• 회원가입
  • 로그인
  • 구글아이디로 로그인

[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>

  

결과보기



분류 제목
HTML_CSS JQ - insertBefore() 메서드 - 선택요소 앞에 요소삽입/요소추가. (= insertBefore…
HTML_CSS JQ - offset() 메서드 ★ - 오프셋 (=xy좌표) 설정/반환. (= offset메서드 = 오프셋메…
HTML_CSS JQ - outerHeight() 메서드 - 요소 높이 반환 (height + padding + border…
HTML_CSS JQ - outerWidth() 메서드 - 요소 너비 반환 (※ padding, border 둘다 포함) (…
HTML_CSS JQ - position() 메서드 - 부모요소 기준으로 요소 위치 반환 (= position메서드 = 포지…
HTML_CSS JQ - prepend() 메서드 - 선택요소 안 시작부분에 내용 삽입 (= prepend메서드 = 프리펜드…
HTML_CSS JQ - prependTo() 메서드 - 선택요소 시작부분에 HTML 요소삽입 (= prependTo메서드 …
HTML_CSS JQ - prop() 메서드 - 속성과 속성값 설정/반환. (= prop메서드 = 프랍메서드 = 프롭메서드)…
HTML_CSS JQ - remove() 메서드 - 선택요소 제거 (= remove메서드 = 리무브 메서드)
HTML_CSS JQ - removeAttr() 메서드 - 1개 이상의 속성 제거 (= removeAttr메서드 = 리무브어…
HTML_CSS JQ - removeClass() 메서드 ★ - 클래스 제거 (= removeClass메서드 = 리무브클래스…
HTML_CSS JQ - removeProp() 메서드 - prop() 메서드로 설정된 속성 제거. (= removeProp…
HTML_CSS JQ - replaceAll() 메서드 - 선택요소를 새 HTML 요소로 대체 (= replaceAll메서드…
HTML_CSS JQ - replaceWith() 메서드 ★ - 선택요소 내용를 새 내용으로 대체/변경 (= replaceW…
HTML_CSS JQ - scrollLeft() 메서드 - 선택요소 가로 스크롤바 위치 설정/반환 (= scrollLeft메…
HTML_CSS JQ - scrollTop() 메서드 ★ - 선택요소 세로 스크롤바 위치 설정/반환 (= scrollTop메…
HTML_CSS JQ - text() 메서드 - 선택요소 텍스트 내용설정/내뇽변경/내용반환. (= text메서드 = 텍스트메…
HTML_CSS JQ - toggleClass() 메서드 ★★★ - 클래스추가/제거 상호전환. (= toggleClass메서…
HTML_CSS JQ - unwrap() 메서드 - 부모요소 제거 (= unwrap메서드 = 언랩 메서드)
HTML_CSS JQ - val() 메서드 ★★★ - value속성 값설정/값반환 (= val메서드 = 밸메서드) ※ 밸류메…
10/15
목록
찾아주셔서 감사합니다. Since 2012