Jquery's fadein 'slow' is too fast

2020-02-23 06:16发布

i'm using the jquery fadein fadeout with the slow option, but it's still a little too fast for me. now i've read that you can only choose between fast and slow, but is there a way to make it slower?

标签: jquery
4条回答
狗以群分
2楼-- · 2020-02-23 06:34

I really dont know how slow you want it but I recoomend something between 2500-4000

$('#Id').fadeIn(3500);

There we go

查看更多
狗以群分
3楼-- · 2020-02-23 06:35

You have two options. The first is to use a number of milliseconds in the call:

$('#myItem').fadeOut(1500); // 1.5 seconds

The second option is to define a custom speed, or to redefine a jQuery native speed:

$.fx.speeds.slow = 1500; // 'slow' now means 1.5 seconds
$.fx.speeds.xslow = 3000; // 'xslow' means 3 seconds
$.fx.speeds.xfast = 100; // 'xfast' means 0.1 seconds

You can then call them as normal:

$('#myItem').fadeOut('slow');
$('#myItem').fadeOut('xslow');
$('#myItem').fadeOut('xfast');

This allows you to redefine speeds on an application-wide basis.

查看更多
▲ chillily
4楼-- · 2020-02-23 06:46

Use a number of milliseconds rather than 'fast' or 'slow'

e.g.

$('#myID').fadeIn(100, function() {
  // complete
});

See http://api.jquery.com/fadeIn/

查看更多
5楼-- · 2020-02-23 06:55

In addition to 'slow'/'fast', the fadeIn function also takes a timespan in milliseconds so you can make it take however long you want:

$('#someId').fadeIn(3000); // 3 second fade in
查看更多
登录 后发表回答