Skip to content

Instantly share code, notes, and snippets.

Created July 27, 2010 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3105f4f6b9a6bded949b to your computer and use it in GitHub Desktop.
Save anonymous/3105f4f6b9a6bded949b to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Titre</title>
<script type="text/javascript">
var blocs = new Array('texte_image1','texte_image2','texte_image3');
function hideAll() {
for(x in blocs) {
document.getElementById(blocs[x]).style.display = 'none';
}
}
function display(id) {
hideAll();
var div = document.getElementById(id);
div.style.display = (div.style.display == 'none') ? 'block' : 'none' ;
}
</script>
<style type="text/css">
.hidden { display: none; }
</style>
</head>
<body>
<div>
<input type="button" value="Afficher n°1" onclick="display('texte_image1')" />
<input type="button" value="Afficher n°2" onclick="display('texte_image2')" />
<input type="button" value="Afficher n°3" onclick="display('texte_image3')" />
</div>
<div id="texte_image1" class="hidden">Contenu de premier div</div>
<div id="texte_image2" class="hidden">Contenu de second div</div>
<div id="texte_image3" class="hidden">Contenu de troisième div</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment