jQuery snippet code which allows to do something once after 5 second. it can be used to automate an action by a once only time based trigger. It works like very similar to the jQuery setInterval() Function.

EXAMPLE – 1 :

setTimeout(function() {
// Do something after 5 seconds
}, 5000);

If you want to clear any timer values which stored previously, You can use the ClearTimeout()

timeout = setTimeout('timeout_trigger()', 3000);
clearTimeout(timeout);

EXAMPLE – 2 :

jQuery(document).ready(function () {
//hide a div after 3 seconds
setTimeout( "jQuery('#div').hide();",3000 );
});

Or you can also use this :

jQuery(document).ready(function () {
//hide a div after 3 seconds
setTimeout(function(){ jQuery("#div").hide(); }, 3000);
});
<!-- show a message for 2 seconds after you click the button -->
<input type="button" value="click me"
onclick="setTimeout('window.alert('Hello!')', 2000)" />

Or else you can use it as function like this :
<script language="Javascript">

function timeout_trigger() {
window.alert('Hello!');
}

function timeout_init() {
setTimeout('timeout_trigger()', 2000);
}

</script>
<input type="button" value="click me" onclick="timeout_init()" />