jquery delay_jQuery delay()函数

jquery delay

jQuery delay function is used to delay the execution of items in the queue. This method sets a timer to delay the execution.

jQuery延迟功能用于延迟队列中项目的执行。 此方法设置计时器以延迟执行。

jQuery delay() (jQuery delay())

Here is the general syntax for using jQuery delay() function:

这是使用jQuery delay()函数的一般语法:

selector.delay(Integer speed, String queueName)

selector.delay(Integer speed, String queueName)

speed defines the duration of the delay effect. Durations are specified in milliseconds.

速度定义延迟效果的持续时间。 持续时间以毫秒为单位。

queueName is the name of the queue on which delay function will execute. This is an optional argument. Default value is fx which is the standard effects queue.

queueName是将在其上执行延迟功能的队列的名称。 这是一个可选参数。 默认值为fx ,这是标准效果队列。

jQuery延迟功能 (jQuery delay function)

Following example demonstrates the application of jQuery delay function to delay animation.

下面的示例演示了jQuery延迟函数在延迟动画中的应用。

<!doctype html>
<html>
<head>
<title>jQuery delay Function</title>
<style>
div {
position: absolute;
width: 70px;
height: 70px;
float: left;
}
.div1{
background-color: red;
left: 0;
}
.div2{
background-color: black;
left: 80px;
}
</style>
<script src="jquery-3.2.1.min.js"></script>
</head>
<body>
<p><button>jQuery Delay Demo</button></p>
<div class="div1"></div>
<div class="div2"></div>
<script>
$( "button" ).click(function() {
$( "div.div1" ).toggle( 300 ).delay( 2000 ).fadeIn( 400 );
$( "div.div2" ).toggle( 300 ).slideDown( 1000 );
});
</script>
</body>
</html>

As you can see that in above example, fadeIn effect is delayed by 2 seconds using jQuery delay() function.

如您所见,在上面的示例中,使用jQuery delay()函数将fadeIn效果延迟了2秒。

Below image shows the jQuery delay function usage in action to delay animation.

下图显示了用于延迟动画的jQuery延迟函数用法。

jQuery延迟动画直播演示 (jQuery delay animation live demo)

Click on the below button to see the above example output.

单击下面的按钮以查看上面的示例输出。

演示地址

jQuery delay function is very helpful for jQuery animation. This method is added to the 1.4 version of jQuery. This method is used at its best to delay the queued effects in jQuery.

jQuery延迟功能对于jQuery动画非常有用。 此方法已添加到jQuery的1.4版本中。 最好使用此方法来延迟jQuery中排队的效果。

Reference: API Doc

参考: API文档

翻译自: https://www.journaldev.com/4652/jquery-delay-function

jquery delay

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值