jQuery Effect fadeOut()วิธี การ
ตัวอย่าง
เลือนองค์ประกอบ <p> ทั้งหมด:
$("button").click(function(){
$("p").fadeOut();
});
ความหมายและการใช้งาน
วิธี fadeOut() จะค่อยๆ เปลี่ยนความทึบสำหรับองค์ประกอบที่เลือก จากที่มองเห็นได้เป็นซ่อนอยู่ (เอฟเฟกต์จาง)
หมายเหตุ : องค์ประกอบที่ซ่อนอยู่จะไม่ปรากฏเลย (ไม่ส่งผลต่อเค้าโครงของหน้าอีกต่อไป)
เคล็ดลับ:วิธีนี้มักใช้ร่วมกับวิธีfadeIn ()
ไวยากรณ์
$(selector).fadeOut(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the fading effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the fadeOut() method is completed
To learn more about callback, visit our jQuery Callback chapter |
ลองด้วยตัวคุณเอง - ตัวอย่าง
วิธีการใช้พารามิเตอร์ความเร็วเพื่อระบุความเร็วของเอฟเฟกต์การซีดจาง
วิธีการใช้พารามิเตอร์การโทรกลับเมื่อค่อยๆ เปลี่ยนความทึบสำหรับองค์ประกอบที่เลือก