+ 4

hello everybody can someone help me please.

hello everybody can someone help me please. I would to create an html page that contain two divs with two table.they must toggle every 5 s and when the users click the toggle must stop, and when it's a double click the toggle must continue.

1st Feb 2019, 10:34 AM
ABDELMOUGHIT GARDAM
ABDELMOUGHIT GARDAM  - avatar
2 Réponses
+ 1
i create the toggle and it work with this : var intervalID = setInterval(function() { $("#mydiv2").toggle(); $("#mydiv1").toggle(); }, 5000); setTimeout(function() { clearInterval(intervalID); }, 20000); but the click and double click didnt work
1st Feb 2019, 3:42 PM
ABDELMOUGHIT GARDAM
ABDELMOUGHIT GARDAM  - avatar
+ 5
You can use setInterval method with toggle() method on HTML elements. And clearInterval method with the click event. A sample code. //Assume you have 2 divs with id a and b. //toggling the element every 5 seconds for div#a var a1 = setInterval(()=>{ $("#a").toggle(); },5000); //toggling the element every 5 seconds for div#b var b1 = setInterval(()=>{ $("#b").toggle(); },5000) //5s is mentioned in 5000 ms //clearing the interval upon clicking $("#b").click(()=>{ clearInterval(b1); }); $("#a").click(()=>{ clearInterval(a); }); $("#a").dblclick(()=>{ //TODO: use the above snippet with some decision making statements. });
1st Feb 2019, 11:24 AM
Seniru
Seniru - avatar