I saw that you finally chose the answer, but decided that I would drop my two cents, as I made this example with a long explanation. Hope this helps you in understanding.
In the first example, there is a variable for the timer, so your 10 seconds can be reset every time a change occurs. Thus, by clicking on elements that have class names, also reset the timer.
Side Note: In the following examples I use . on () . If you use jQuery before 1.7, you can just replace it . on () with . live () .
var tmrShowHide;
Thus, without comment, it is as simple as:
var tmrShowHide; function divShowHide() { clearTimeout(tmrShowHide); $('#pf-blue-area, #pf-orange-area').toggle(); tmrShowHide = setTimeout(divShowHide, 10000); } $(function() { $(document).on('click', '.dab, .pfs', divShowHide); tmrShowHide = setTimeout(divShowHide, 10000); })
This next example is much shorter in that it does not reset the timer, so clicking on a class element to make a change will not prevent it from changing every 10 seconds.
function divShowHide(e) {
Thus, without comment, it is as simple as:
function divShowHide(e) { $('#pf-blue-area, #pf-orange-area').toggle(); } $(function() { $(document).on('click', '.dab, .pfs', divShowHide); setInterval(divShowHide, 10000); })