¿Cómo usar js para escribir un programa cuyo color cambia con el reloj?
lthtml gt
lt script gt
ventana.onload? =?función()? {
var? ¿reloj? =?document.getElementById('reloj ').
var? ¿color? =?['rojo',? 'verde',? amarillo',? 'azul',? 'negro',? 'oro',? 'color naranja',? 'gris',? 'rosa',? granate'];? //matriz de colores del reloj
setInterval(function()?{
var? now?=?new?date();
clock.innerHTML ?= ?now.getFullYear()? ?(now.getMonth() ?Mes? ?now.getHours()? ?now.getMinutes()? ':'? ?now . obtener segundos();
var? =?Math.floor(Math.random().*?color.length ? ?1)?-?1;? //Número aleatorio
Reloj.Estilo.Color? radom];? //Establecer color aleatorio
} 1000)
}
lt/script gt;
ltbody gt p>
lt span? id="reloj"? estilo = "tamaño de fuente: 20px;" gt lt/spangt.
lt/cuerpo gt;
lt/html gt
;