How to hide a element automaticaly after few seconds using jQuery
While developing a web application in some cases we show some alert messages, success messages or some information to the users. After showing these type of messages users has to close the information box manually. In this tutorial let’s see how to hide a element automaticaly after few seconds using jQuery.
Lets say that we want to hide the following div after 5 seconds.
<div id=”successMessage”>Project saved successfully!</div>
To do this we can use jQuery hide() function and delay() functions
hide() – Hides the matched elements.
Ex: $( ".target" ).hide();
delay() – Set a timer to delay execution of subsequent items in the queue.
Ex: $( "#foo" ).delay( 800 ).fadeIn( 400 );
Okay now continuing to our tutorial we have to use both of these functions with our target element.
Adding above line to your code will hide a element automaticaly after 5 seconds.🔥0