jQuery hide() Metode

Metode Efek jQuery

Contoh

Sembunyikan semua elemen <p>:

$("button").click(function(){
  $("p").hide();
});

Definisi dan Penggunaan

Metode hide() menyembunyikan elemen yang dipilih.

Tip: Ini mirip dengan properti CSS display:none.

Catatan : Elemen tersembunyi tidak akan ditampilkan sama sekali (tidak lagi mempengaruhi tata letak halaman).

Tip: Untuk menampilkan elemen tersembunyi, lihat metode show() .


Sintaksis

$(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


Cobalah Sendiri - Contoh


Cara menggunakan parameter kecepatan saat menyembunyikan/menampilkan elemen.


Cara menggunakan parameter callback saat menyembunyikan/menampilkan elemen.


Metode Efek jQuery