hello = document.querySelector("#divHello"); flgW = false; say(); function say() { if(flgW) { hello.innerHTML = 'Ho!'; } else { hello.innerHTML = 'Hi!'; } flgW = !flgW; setTimeout(say, 1000); }
<div id="divHello"> </div>
#divHello { background: black; color: white; border-radius: 10px; width: 100px; height: 100px; margin: auto; text-align: center; display: table-cell; vertical-align: middle; font-size: 40px; }