I want a text to change after three seconds once the user has clicked. I want that the user clicks and put some text in the screen (this already works) and after three seconds the text changes to nothing (""). The code I tried is:
JavaScript:
function almuerzo() {
var date = new Date();
var horas = date.getHours();
var minutos = (date.getMinutes() < 10? '0' : '')+ date.getMinutes();
document.getElementById("accion").innerHTML = horas + ":" + minutos + " Almuerzo";
}
function cambio() {
var contador = 0;
setInterval(cambio, 1000);
contador++;
if(contador == 3)
document.getElementById("accion").innerHTML = "";
}
HTML:
<h1 id="accion" class="t-accion"></h1>
<img src="img/almuerzo.png" class="i-almuerzo" height="100px" onclick="almuerzo()" onclick="cambio()" />