What is the best way to handle the result between return or use innerhtml
Here is an example. I have a page with element with id weekday. As I have
done here I just add the result to the innerHTML for the id element
weekday.
Now to my question is it more generic to just return the actual day in the
week for example Sunday and then use the innerHTML in the actual page that
is calling the Weekday function ?
What is your sugestion about this matter ?
function Weekday()
{
var currentTime = new Date();
//Get currrent day by indexing in the array
var weekday = new Array(7);
weekday[0] = "Monday";
weekday[1] = "Tuesday";
weekday[2] = "Wednesday";
weekday[3] = "Thusday";
weekday[4] = "Friday";
weekday[5] = "Saturday";
weekday[6] = "Sunday";
document.getElementById("weekday").innerHTML =
weekday[currentTime.getDay()] + ":";
}
//tony
No comments:
Post a Comment