display content on clicking code example
Example 1: how to use javascript to hide content and show through link
$(document).ready(function() {
$('li').click(function () {
$('.content:visible').hide();
$('.content').eq($(this).index()).show();
});
});
Example 2: hide automatically show and hide javascript
function toggleClock() {
var myClock = document.getElementById('clock');
var displaySetting = myClock.style.display;
var clockButton = document.getElementById('clockButton');
if (displaySetting == 'block') {
myClock.style.display = 'none';
clockButton.innerHTML = 'Show clock';
}
else {
myClock.style.display = 'block';
clockButton.innerHTML = 'Hide clock';
}
}