jQuery ซ่อน ()เมธอด

❮ วิธีการเอฟเฟกต์ 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:

  • milliseconds
  • "slow"
  • "fast"
easing Optional. Specifies the speed of the element in different points of the animation. Default value is "swing"

Possible values:

  • "swing" - moves slower at the beginning/end, but faster in the middle
  • "linear" - moves in a constant speed
Tip: More easing functions are available in external plugins
callback Optional. A function to be executed after the hide() method is completed

To learn more about callback, visit our jQuery Callback chapter


ลองด้วยตัวคุณเอง - ตัวอย่าง


วิธีการใช้พารามิเตอร์ความเร็วเมื่อซ่อน/แสดงองค์ประกอบ


วิธีการใช้พารามิเตอร์ callback เมื่อทำการซ่อน/แสดงองค์ประกอบ


❮ วิธีการเอฟเฟกต์ jQuery