Is it possible to automatically hide an element in a web page 5 seconds after the form loads using jQuery?
Basically, I\'ve got
This is how you can set the timeout after you click.
$(".selectorOnWhichEventCapture").on('click', function() {
setTimeout(function(){
$(".selector").doWhateverYouWantToDo();
}, 5000);
});
//5000 = 5sec = 5000 milisec
$(function() {
// setTimeout() function will be fired after page is loaded
// it will wait for 5 sec. and then will fire
// $("#successMessage").hide() function
setTimeout(function() {
$("#successMessage").hide('blind', {}, 500)
}, 5000);
});
Note: In order to make you jQuery function work inside setTimeout you should wrap it inside
function() { ... }
jQuery(".success_mgs").show(); setTimeout(function(){ jQuery(".success_mgs").hide();},5000);
You use setTimeout on you runEffect function :
function runEffect() {
setTimeout(function(){
var selectedEffect = 'blind';
var options = {};
$("#successMessage").hide(selectedEffect, options, 500)
}, 5000);
}
$('#selector').delay(5000).fadeOut('slow');
I think, you could also do something like...
setTimeout(function(){
$(".message-class").trigger("click");
}, 5000);
and do your animated effects on the event-click...
$(".message-class").click(function() {
//your event-code
});
Greetings,