1
My Javascript code has a Date object, however this script only works in Chrome and IE, and in Firefox nothing appears, because it happens?
Code:
function relogio(elemento){
var target = document.querySelector(elemento);
var rel = new Date();
var hora = rel.getHours();
var minuto = rel.getMinutes();
var segundo = rel.getSeconds();
if(hora < 10){
hora = "0"+hora;
}
if(minuto < 10){
minuto = "0"+minuto;
}
if(segundo < 10){
segundo = "0"+segundo;
}
target.innerText = hora+":"+minuto+":"+segundo;
}
window.setInterval("relogio('#relogio')", 1000);
<div id="relogio">
</div>
Also available on jsfiddle.
Please submit only Javascript solutions.