document.getElementById("apDiv1").style.display = "none" ; document.getElementById("apDiv2").style.display = "none" ;
<head> <style type="text/css"> #apDiv1 { position: absolute; width: 200px; height: 485px; display: block; left: 175px; top: 6px; } #apDiv2 { position: absolute; width: 200px; height: 484px; display:block; left: 378px; top: 6px; } #apDiv3 { position: absolute; width: 404px; height: 485px; display:none; left: 174px; top: 6px; } </style> <script> function visibilite(thingId) { var targetElement; targetElement = document.getElementById(thingId) ; if (targetElement.style.display == "none") { targetElement.style.display = "block" ; } else { targetElement.style.display = "none" ; } } </script> </head>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<script> function visibilite() { for (i=1;i<=3;i++){ thingId = "apDiv"+i targetElement = document.getElementById(thingId) ; if (targetElement.style.display == "none") { targetElement.style.display = "block" ; } else { targetElement.style.display = "none" ; } } } </script>