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

后端 未结 4 1774
面向向阳花
面向向阳花 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:42

    You can do this by using toggle function on classList

    function hide(elementId) {
      document.getElementById(elementId).classList.toggle('hidden');
    }
    
    setInterval(hide, 6000, 'xhide');
    .hidden {
      display: none;
    }

    Hello World

提交回复
热议问题