显示元素并在1秒后将其隐藏 [英] Show an element and hide it after 1 second

查看:135
本文介绍了显示元素并在1秒后将其隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下元素:

<div class="text hide">Hello SO</div>

我用jQuery这样显示它:

I show it with jQuery like this:

$('.text').addClass('show').removeClass('hide');

所以我的<div>出现了.

我现在希望它褪色以在1秒后再次隐藏.

I want now it fade to hide again after 1 second.

能请你帮我吗?

谢谢

推荐答案

您可以使用 delay() ,然后使用 show() 显示该项目和 hide() 隐藏该项目

You can use delay() and use show() to show the item and hide() to hide the item

$('.text').show(1).delay(1000).hide(1);

注意: :您需要设置show()hide()的持续时间才能使用deley()

Note : You need to set duration for show() and hide() to work the deley()

这篇关于显示元素并在1秒后将其隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆