.queue() - Effects , jQuery |
.queue() เป็นการใช้ Effects กับ .queue() ใช้สำหรับแสดง หรือ show queue ทีกำลังทำงานอยู่ในขณะนั้น
Syntax
.queue( [ queueName ] )
.queue( [queueName,] newQueue )
.queue( [queueName,] callback( next ) )
Example 1 ตัวอย่างการใช้งาน .queue()
Effectsqueue1.html

<html>
<head>
<title>ThaiCreate.Com jQuery Tutorials</title>
<style>
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:60px;
background:green; display:none; }
div.newcolor { background:blue; }
p { color:red; }
</style>
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var div = $("div");
function runIt() {
div.show("slow");
div.animate({left:'+=200'},2000);
div.slideToggle(1000);
div.slideToggle("fast");
div.animate({left:'-=200'},1500);
div.hide("slow");
div.show(1200);
div.slideUp("normal", runIt);
}
function showIt() {
var n = div.queue("fx");
$("span").text( n.length );
setTimeout(showIt, 100);
}
runIt();
showIt();
});
</script>
</head>
<body>
<p>The queue length is: <span></span></p>
<div></div>
</body>
</html>
Screenshot

คำอธิบาย (ภาษาไทย)
จากตัวอย่างเป็นการใช้ Effects กับ .queue() ในการจัดการกับ element ที่อ้างถึง
Example 2 ตัวอย่างการใช้งาน .queue()
Effectsqueue2.html

<html>
<head>
<title>ThaiCreate.Com jQuery Tutorials</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 type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document.body).click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},2000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
});
});
</script>
</head>
<body>
Click here...
<div></div>
</body>
</html>
Screenshot

คำอธิบาย (ภาษาไทย)
จากตัวอย่างเป็นการใช้ Effects กับ .queue() ในการจัดการกับ element ที่อ้างถึง

Example 3 ตัวอย่างการใช้งาน .queue()
Effectsqueue3.html

<html>
<head>
<title>ThaiCreate.Com jQuery Tutorials</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 type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/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").queue("fx", []);
$("div").stop();
});
});
</script>
</head>
<body>
<button id="start">Start</button>
<button id="stop">Stop</button>
<div></div>
</body>
</html>
Screenshot

คำอธิบาย (ภาษาไทย)
จากตัวอย่างเป็นการใช้ Effects กับ .queue() ในการจัดการกับ element ที่อ้างถึง
ลิ้งค์ที่ควรศึกษา
Go to : jQuery Selectors : jQuery Selectors and Element
Go to : jQuery Effects : jQuery and Effects
เกี่ยวกับบทความ
ส่วนหนึ่งของบทความได้เรียบเรียงและแปลจากเว็บไซต์ jQuery.Com โค้ดตัวอย่างคำสั่งนี้อยู่ภายใต้สัญญาอนุญาตของ GFDL สามารถนำโค้ดและคำสั่งใช้งานได้ฟรี สงวนลิขสิทธิ์เฉพาะคำอธิบายภาษาไทย
|
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท
|
|
|
By : |
ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ) |
|
Score Rating : |
   |
|
|
Create/Update Date : |
2011-09-22 21:44:06 /
2017-03-19 14:07:35 |
|
Download : |
No files |
|
Sponsored Links / Related |
|
|
|
|
|
|
|