I have been trying to make a div fade in evey 30sec and out after 30sec
setInterval(function(){$('#myDiv').toggle();}, 300);
$("#popupboxdis").fadeIn("fast");
$("#popupboxdis").fadeOut("fast");
I have been trying to make a div fade in evey 30sec and out after 30sec
setInterval(function(){$('#myDiv').toggle();}, 300);
$("#popupboxdis").fadeIn("fast");
$("#popupboxdis").fadeOut("fast");
The setInterval time is in milliseconds:
setInterval(function(){
$('#myDiv').toggle('normal');
}, 30000);
Notice the extra 0
s. As it is right now it will try to toggle the element every 300 milliseconds or .3 seconds which is probably resulting in some wacky behavior. Also, the code above should do what you described, I am not sure where the other 2 lines come into play...
Also note that without a time string ('slow', 'normal', 'fast') or a time in ms (1000, 2000) as an argument, toggle
will simply hide and show the elements without the fading animation you are looking for.
I guess you are trying to toggle between fadeOut and fadeIn.
setInterval(function() {
$('#myDiv').toggle(function() {
$(this).fadeOut('fast');
}, function() {
$(this).fadeIn('fast');
});
}, 30000);