Phương thức jQuery hide ()

❮ Phương thức hiệu ứng jQuery

Thí dụ

Ẩn tất cả các phần tử <p>:

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

Định nghĩa và Cách sử dụng

Phương thức hide () ẩn các phần tử đã chọn.

Mẹo: Điều này tương tự với hiển thị thuộc tính CSS: none.

Lưu ý : Các phần tử ẩn sẽ hoàn toàn không được hiển thị (không còn ảnh hưởng đến bố cục của trang).

Mẹo: Để hiển thị các phần tử ẩn, hãy xem phương thức show () .


Cú pháp

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


Hãy tự mình thử - Ví dụ


Cách sử dụng tham số tốc độ khi ẩn / hiện một phần tử.


Cách sử dụng tham số callback khi ẩn / hiện một phần tử.


❮ Phương thức hiệu ứng jQuery