Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show an element and hide it after 1 second

Tags:

jquery

I have the following element:

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

I show it with jQuery like this:

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

So my <div> is show.

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

Could you please help me ?

Thanks

like image 319
user3396984 Avatar asked Dec 25 '22 12:12

user3396984


1 Answers

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

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

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

like image 198
Pranav C Balan Avatar answered Jan 12 '23 00:01

Pranav C Balan