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