Phương thức jQuery Effect fadeTo ()
Thí dụ
Thay đổi dần độ mờ của tất cả các phần tử <p>:
$("button").click(function(){
$("p").fadeTo(1000, 0.4);
});
Định nghĩa và Cách sử dụng
Phương thức fadeTo () dần dần thay đổi độ mờ, đối với các phần tử đã chọn, thành độ mờ được chỉ định (hiệu ứng mờ dần).
Cú pháp
$(selector).fadeTo(speed,opacity,easing,callback)
Parameter | Description |
---|---|
speed | Required. Specifies the speed of the fading effect. Possible values:
|
opacity | Required. Specifies the opacity to fade to. Must be a number between 0.00 and 1.00 |
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 fadeTo() 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ố gọi lại khi làm mờ dần một phần tử.