Jquery's fadein 'slow' is too fast

后端 未结 4 750
旧时难觅i
旧时难觅i 2020-12-29 04:29

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 th

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 05:03

    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.

提交回复
热议问题