jQuery fadeIn()วิธี การ
ตัวอย่าง
จางหายไปในองค์ประกอบ <p> ทั้งหมด:
$("button").click(function(){
$("p").fadeIn();
});
ความหมายและการใช้งาน
วิธี fadeIn() จะค่อยๆ เปลี่ยนความทึบสำหรับองค์ประกอบที่เลือก จากซ่อนเป็นมองเห็นได้ (เอฟเฟกต์จาง)
หมายเหตุ : องค์ประกอบที่ซ่อนอยู่จะไม่ปรากฏเลย (ไม่ส่งผลต่อเค้าโครงของหน้าอีกต่อไป)
เคล็ดลับ:วิธีนี้มักใช้ร่วมกับวิธีfadeOut ()
ไวยากรณ์
$(selector).fadeIn(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 fadeIn() method is completed
To learn more about callback, visit our jQuery Callback chapter |
ลองด้วยตัวคุณเอง - ตัวอย่าง
วิธีการใช้พารามิเตอร์ความเร็วเพื่อระบุความเร็วของเอฟเฟกต์การเฟด
วิธีการใช้พารามิเตอร์ callback เมื่อเฟดเข้าและออกจากองค์ประกอบ