Monday, October 13, 2014

Lab 7: Time and Date in JavaScript


  In lab 7, we learned how to add the current date/time on a website using JavaScript. We attached our JavaScript to our html document.  I added an alert box that  pops up saying "Current Time and Date!" if someone visits my lab. I used the code <body onload="myFunction ()"> in my html document for the time. "myFunction" is the function for the timer and for the date to 
show up, I used "demo" as the  
function.



The code for the date in html is <p id="demo"></p> and in my JavaScript, its "document.getElementById ("demo").innerHTML=t;" The importance of adding <body onload="myFunction()"> and <p id="demo"></p> to our html document was to make it visible on the website. I can use this skill in the future to add the date/time to a lab or a project.



No comments:

Post a Comment