Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  18] [ 7]  / answers: 1 / hits: 20582  / 8 Years ago, mon, february 29, 2016, 12:00:00

I would like to set an interval of 5 seconds between each alert. Found this thread:



setInterval(function() {
alert(Message to alert every 5 seconds);
}, 5000);


But where do I put the setInterval() in order to alert every 5 seconds?



$(window).scroll(function() {
if (checkVisible($('#footer'))) {
alert(I DONT SEE A FOOTER);
} else {
alert(EUREKA - I SEE A FOOTER);
}
});

function checkVisible(elm, eval) {
eval = eval || visible;
var vpH = $(window).height(), // Viewport Height
st = $(window).scrollTop(), // Scroll Top
y = $(elm).offset().top,
elementHeight = $(elm).height();

if (eval == visible)
return ((y < (vpH + st)) && (y > (st - elementHeight)));

if (eval == above)
return ((y < (vpH + st)));
}


Many thanks in advance.


More From » jquery

 Answers
54

You can put in load function



$(document).ready(function()
{
setInterval(function() {
alert(Message to alert every 5 seconds);
}, 5000);
});

[#63113] Friday, February 26, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
Sat, Sep 25, 21, 00:00, 3 Years ago
Sun, Jan 31, 21, 00:00, 3 Years ago
Wed, Dec 2, 20, 00:00, 4 Years ago
Fri, Oct 23, 20, 00:00, 4 Years ago
;