תיאור:
מוחק מתור כל האלמנטים עדיין לא הופעלו.
ארגומנטים
clearQueue( [ queueName ] )
הוספה בגרסה: 1.4
queueName (אופציאונלי)
מחרוזת שמכילה שם של התור.
בברירת מחדל
fx,
תור של אפקטים סטנדרטים.
כאשר שיטה
.clearQueue()
מופעלת,
כל הפונקציות בתור שעדיין לא הופעלו נמחקות מהתור.
כאשר משתמש ללא ארגומנט,
.clearQueue()
מוחקת פונקציות שנשארו מ-
fx,
תור אפקטים סטנדטים.
במקרה הזה זה דומה ל-
.stop(true).
עם זאת, בזמן שבשיטה
.stop(true)
ניתן להשתמש רק עם אנימציה, ב-.clearQueue()
ניתן גם להשתמש למחיקה כל פונקציה שהוספה לתור כללי של
jQuery
עם שיטה
.queue().דוגמה
מוחק תור.
$("#start").click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},5000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},1500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
});
$("#stop").click(function () {
$("div").clearQueue();
$("div").stop();
});
דוגמה - קוד מלא:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<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="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("#start").click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},5000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},1500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
});
$("#stop").click(function () {
$("div").clearQueue();
$("div").stop();
});
});
</script>
</head>
<body>
<button id="start">Start</button>
<button id="stop">Stop</button>
<div></div>
</body>
</html>
האם מידע זה היה מועיל?

