제이쿼리 .clearQueue ([queueName])

· 8년 전 · 1344

제이쿼리 .clearQueue ([queueName])


설명 : 아직 실행되지 않은 모든 항목을 대기열에서 제거하십시오.


.clearQueue()메소드가 호출되어 실행되지 않은 대기열에 모든 함수는 큐로부터 제거된다. 인수없이 사용 하면 표준 효과 대기열 .clearQueue()에서 나머지 기능을 제거합니다 fx. 이 방법으로 그것은 비슷합니다 .stop(true). 그러나이 .stop()메소드는 애니메이션과 함께 사용하기위한 것이지만 메소드를 사용 .clearQueue()하여 일반 jQuery 대기열에 추가 된 모든 함수를 제거하는 데에도 사용할 수 있습니다 .queue().


예:

대기열을 비우십시오.




<!doctype html>

<html lang="en">

<head>

  <meta charset="utf-8">

  <title>clearQueue demo</title>

  <style>

  div {

    margin: 3px;

    width: 40px;

    height: 40px;

    position: absolute;

    left: 0px;

    top: 30px;

    background: green;

    display: none;

  }

  div.newcolor {

    background: blue;

  }

  </style>

  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>

</head>

<body>

 

<button id="start">Start</button>

<button id="stop">Stop</button>

<div></div>

 

<script>

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

  var myDiv = $( "div" );

  myDiv.show( "slow" );

  myDiv.animate({

    left:"+=200"

  }, 5000 );

 

  myDiv.queue(function() {

    var that = $( this );

    that.addClass( "newcolor" );

    that.dequeue();

  });

 

  myDiv.animate({

    left:"-=200"

  }, 1500 );

  myDiv.queue(function() {

    var that = $( this );

    that.removeClass( "newcolor" );

    that.dequeue();

  });

  myDiv.slideUp();

});

 

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

  var myDiv = $( "div" );

  myDiv.clearQueue();

  myDiv.stop();

});

</script>

 

</body>

</html>

|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
jQuery 8년 전 조회 1,334
jQuery 8년 전 조회 2,123
jQuery 8년 전 조회 1,580
jQuery 8년 전 조회 1,777
jQuery 8년 전 조회 1,764
jQuery 8년 전 조회 2,052
jQuery 8년 전 조회 1,979
jQuery 8년 전 조회 1,483
jQuery
[jQuery]
8년 전 조회 1,951
PHP 8년 전 조회 6,941
jQuery 8년 전 조회 2,597
jQuery 8년 전 조회 1,632
jQuery 8년 전 조회 1,713
jQuery 8년 전 조회 1,855
jQuery 8년 전 조회 1,345
jQuery 8년 전 조회 1,900
jQuery 8년 전 조회 1,655
jQuery 8년 전 조회 1,942
jQuery 8년 전 조회 2,003
jQuery 8년 전 조회 1,623
jQuery 8년 전 조회 1,635
jQuery 8년 전 조회 1,590
jQuery 8년 전 조회 1,265
jQuery 8년 전 조회 1,428
jQuery 8년 전 조회 1,460
jQuery 8년 전 조회 1,373
jQuery 8년 전 조회 2,266
jQuery 8년 전 조회 1,749
PHP 8년 전 조회 3,781
jQuery 8년 전 조회 1,653
🐛 버그신고