Displaying the clock java

09.43

Now That We have our time string ready for display, the next stepis to display it in the Web page. Now that we have a string of timewe are ready for display, the next step is to display it on a webpage. To do this, We first create a div container in the markupto hold the time display: To do this, we first create a div containerin the markup to hold the time display:

  

By Placing the inside the span element, we're creating a child textnode for the div in the DOM. By placing in the span element, wecreate the text node children for the span in the DOM. Cans Wethen populate the container with our time by retrieving this stringchild text node then its nodeValue property settings, as follows: Wecan then fill the container with the string of our time by taking thistext node children then setting nodeValue property, as follows:

document.getElementById("clock").firstChild.nodeValue = currentTimeString;

0 Comment