The related usage of setInterval and setTimeout

problem description

enter a floating entrance at the bottom of the H5 page (similar to a semi-transparent pop-up frame fixed at the bottom of the window) for half a minute, automatically hide, hide for half a minute and then continue to show for half a minute, and so on. How to solve

with setInterval and setTimeout

the environmental background of the problems and what methods you have tried


related codes

/ / Please paste the code text below (do not replace the code with pictures)

//
//60
setInterval(closeFun,60000);
//setTimeout30setTimeout30
function closeFun(){
    setTimeout(function(){
        $("-sharpguide").fadeOut();
        setTimeout(function(){
            $("-sharpguide").fadeIn();
        },30000);
    },30000);
}


 //
//60
setInterval(closeFun,60000);
function closeFun(){
    setTimeout(function(){
        $("-sharpguide").fadeOut();            
    },30000);
    setTimeout(function(){
        $("-sharpguide").fadeIn();
    },30000);
}

what result do you expect? What is the error message actually seen?

problem description



530

the platform version of the problem and what methods you have tried

Apr.02,2021

setInterval (() = > {

$("-sharpguide").toggle();

}, 30000)


setTimeout is not required.

flag = 'in';
setInterval(closeFun,30000);
//setTimeout30
function closeFun(){
    if(flag == 'in'){
        $("-sharpguide").fadeOut();
        flag = 'out';
    }else{
        $("-sharpguide").fadeIn();
        flag = 'in';
    }
}
Menu