简体   繁体   English

在隐藏和显示之间暂停

[英]Pause between hide and show

 $(".swap-image-1a").hide();
 $(".swap-image-1b").show().sleep(3000);
 $(".swap-image-1b").hide();
 $(".swap-image-1a").show().sleep(3000);
 $(".swap-image-1a").hide();
 $(".swap-image-1c").show();

Can someone show me how to properly make these images pause between hiding and showing them? 有人可以告诉我如何正确地使这些图像在隐藏和显示之间暂停吗? Thanks so much. 非常感谢。

You could use a callback function: 您可以使用回调函数:

$(".swap-image-1b").show(3000, function() {
  $(".swap-image-1b").hide();
});

The .hide() and .show() methods accepts the next params: .show() .hide().show()方法接受以下参数:


.show( [duration ] [, complete ] )

duration (default: 400) 持续时间(默认值:400)

Type: Number or String A string or number determining how long the animation will run. 类型:数字或字符串一个字符串或数字,确定动画将运行多长时间。

complete 完成

Type: Function() A function to call once the animation is complete, called once per matched element. 类型:Function()动画完成后调用的函数,每个匹配元素调用一次。


.show( options )

options 选项

Type: PlainObject A map of additional options to pass to the method. 类型:PlainObject传递给该方法的其他选项的映射。

You can find more details in the documentation: 您可以在文档中找到更多详细信息:

您可以指定$ .show()和$ .hide()函数的持续时间。

$('#example').show(1000) // 1 second

You should use the sleep() method after hiding and before showing, not after showing. 隐藏后和显示前,而不是显示后,应使用sleep()方法。

 $(".swap-image-1a").hide().sleep(3000);
 $(".swap-image-1b").show();
 $(".swap-image-1b").hide().sleep(3000);
 $(".swap-image-1a").show();
 $(".swap-image-1a").hide().sleep(3000);
 $(".swap-image-1c").show();

You can also specify the duration for the hide() method as the first argument. 您还可以将hide()方法的持续时间指定为第一个参数。

 $(".swap-image-1a").hide(3000);//3 seconds
 $(".swap-image-1b").show();
 $(".swap-image-1b").hide(3000);
 $(".swap-image-1a").show();
 $(".swap-image-1a").hide(3000);
 $(".swap-image-1c").show();

See the documentation: 请参阅文档:

.hide()

.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM