HTML and CSS Reference
In-Depth Information
You'll add these two commands to the showTime() function and then reload the
Web page.
To change the minutes and seconds formats:
1. Return to the functions.js file in your text editor.
2. Add the following commands before the return statement as shown in Figure 11-33:
// add leading zeros to minutes and seconds less than 10
thisMinute = thisMinute < 10 ? “0” + thisMinute : thisMinute;
thisSecond = thisSecond < 10 ? “0” + thisSecond : thisSecond;
Figure 11-33
revising the minutes and seconds values to show leading zeros
3. Save your changes, and then close the file.
4. Reload or refresh clock.htm in your Web browser. The revised clock displays the
formatted minutes and seconds values. See Figure 11-34.
Figure 11-34
Final display of the countdown clock
value disp l ayed with
a leading zero when
it is less than 10
altafulla/; jbdphotography/
Search WWH ::

Custom Search