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