1 function show() {
2 // get the box
3 var box = document.getElementById('box');
4
5 // get the current value of the box's display property
6 var displaySetting = myClock.style.display;
7
8 // also get the box button, so we can change what it says
9 var showButton = document.getElementById('showButton');
10
11 // now toggle the box and the button text, depending on current state
12 if (displaySetting == 'block') {
13 // box is visible. hide it
14 myClock.style.display = 'none';
15 // change button text
16 clockButton.innerHTML = 'Show box';
17 }
18 else {
19 // box is hidden. show it
20 myClock.style.display = 'block';
21 // change button text
22 clockButton.innerHTML = 'Hide box';
23 }
24 }
25