Hide and unhide a text after 6 seconds in a infinite loop (Html)

后端 未结 4 1723
面向向阳花
面向向阳花 2021-01-23 08:37

Hi i have created this script to hide a text after 6 seconds, But I want that the text must reappear and disappear again back to the infinite every 6 seconds how I can create th

4条回答
  •  离开以前
    2021-01-23 09:33

    The following code will hide the text and re-display it with 6 second intervals in between.

    var textshown = false;
    
    $(document).ready(function() {  
      setInterval(function(){
        if(textshown == false) {
           $('#xhide').show();
           textshown = true;
        } else {
           $('#xhide').hide();
           textshown = false;
        }
      }, 6000);
    });
    
    

    Hello World

提交回复
热议问题