1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <!DOCTYPE html>
<html>
<head>
<style>
.show{
display: none;
}
div{
border: solid black 3px;
cursor: pointer;
}
</style>
</head>
<body>
<div onclick=myFunction()>
<center><h2 id="titre">TITRE</h2></center>
<p class="show" id="paragraphe" >PETIT TEXT.</p>
</div>
<script>
function myFunction() {
var titre = document.getElementById("titre").style.display;
var paragraphe = document.getElementById("paragraphe").style.display;
alert(titre + " et " + paragraphe);
if( titre == "block" ){
document.getElementById("titre").style.display = "none";
document.getElementById("paragraphe").style.display = "block";
}
else{
document.getElementById("paragraphe").style.display = "none";
document.getElementById("titre").style.display = "block";
}
}
</script>
</body>
</html> |