7
I have a function in javascript that returns the day and time for text, for insertion in html, how can I add styles to this text, should I do inside javascript or even in html
function date_time(id){
date = new Date;
year = date.getFullYear();
month = date.getMonth();
months = new Array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outbro', 'Novembro', 'Dezembro');
d = date.getDate();
day = date.getDay();
days = new Array('Domingo', 'Segunda - Feira', 'Terça - Feira', 'Quarta - Feira', 'Quinta - Feira', 'Sexta - Feira', 'Sabado');
h = date.getHours();
if(h<10)
{
h = "0"+h;
}
m = date.getMinutes();
if(m<10)
{
m = "0"+m;
}
s = date.getSeconds();
if(s<10)
{
s = "0"+s;
}
result = 'Bem Vindo, Hoje é '+days[day]+' '+d+' '+months[month]+' '+year;
document.getElementById(id).innerHTML = result;
setTimeout('date_time("'+id+'");','1000');
return true;
}
Html
<span id="date_time"></span>
<script type="text/javascript">window.onload = date_time('date_time');</script>
Upshot
It’s settled, big explanation Thank you ;)
– José Silva
I agree with Paulo Roberto, I think it’s best to change the css is what it’s for :)
– user5282