![]() |
| Le forum de référence en programmation et développement. Articles, cours et tutoriels du débutant au chef de projet et DBA confirmé. | |||||||
|
|||||||
| JavaScript Forum programmation JavaScript. Lire Cours JavaScript, FAQ JavaScript et Sources JavaScript |
![]() |
|
|
Outils de la discussion |
|
|
#1 (permalink) |
|
Invité de passage
![]() Date d'inscription: avril 2007
Messages: 8
|
Bonjour,
J'ai un petit problème d'affichage avec ma fonction javascript onClick. Voici le code : Code :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="screen" type="text/css" title="style" href="../css/style.css" /> <title>Ogame Links</title> <script language="JavaScript"> function affichage2(eltAafficher) { var eltAfficher = document.getElementById(eltAafficher); if (eltAfficher.style.visibility=="visible") { eltAfficher.style.visibility="hidden"; } else { eltAfficher.style.visibility="visible"; } } </script> </head> <body> <div id="en_tete"> <!-- banniere --> </div> <br /> <div id="corps"> <div class="image_corps_haut"> </div> <br /> <center> <img src="../images/ogamelinks_07.jpg" width="69" height="60" alt="ogamelinks_07"/> <img src="../images/ogamelinks_08.jpg" width="700" alt="titre1" value="compte1" onclick="affichage2('un');"/> <br /><br /> <div id="un" style="visibility:hidden"> <table border="2" width="600"> <thead> <tr> <th width="200">Nom</th> <th width="300">Description</th> <th width="100">Lien</th> </tr> </thead> <tbody> <tr> <td><center>Nom lien1</center></td> <td><center>Description lien1</center></td> <td><center>Lien1</center></td> </tr> <tr> <td><center>Nom lien2</center></td> <td><center>Description lien2</center></td> <td><center>Lien2</center></td> </tr> <tr> <td><center>Nom lien3</center></td> <td><center>Description lien3</center></td> <td><center>Lien3</center></td> </tr> </tbody> </table> </div> <br /><br /><br /> <img src="../images/ogamelinks_07.jpg" width="69" height="60" alt="ogamelinks_07"/> <img src="../images/ogamelinks_08.jpg" width="700" alt="titre1" value="compte1" onclick="affichage2('deux');"/> <br /><br /> <div id="deux" style="visibility:hidden"> <table border="2" width="600"> <thead> <tr> <th width="200">Nom</th> <th width="300">Description</th> <th width="100">Lien</th> </tr> </thead> <tbody> <tr> <td><center>Nom lien1</center></td> <td><center>Description lien1</center></td> <td><center>Lien1</center></td> </tr> <tr> <td><center>Nom lien2</center></td> <td><center>Description lien2</center></td> <td><center>Lien2</center></td> </tr> <tr> <td><center>Nom lien3</center></td> <td><center>Description lien3</center></td> <td><center>Lien3</center></td> </tr> </tbody> </table> <br><br><br> </div> <div class="image_corps_bas"> </div> </center> </div> </body> </html> En fait quand je clique sur les images mes divs s'affichent et se cachent bien correctement ca c'est nikel Par contre le problème c'est que quand les div sont cachées il y a un gros espace blanc entre mes deux images, or je voudrais justement que quand les divs sont cachées les images soient collées et quand les div apparaissent alors elles s'intègrent entre les images. Quelqu'un a-t-il une idée pour résoudre se problème? Merci d'avance, Dernière modification par Foyus ; 04/12/2008 à 14h56 |
|
|
|
|
|
#3 (permalink) |
|
Membre du Club
![]() Date d'inscription: septembre 2005
Messages: 86
|
Je confirme display='none' pour masquer et idsplay='block' ou 'inline' pour afficher.. ce qui devrait te donner un truc du genre (pas testé)
Code :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="screen" type="text/css" title="style" href="../css/style.css" /> <title>Ogame Links</title> <script language="JavaScript"> function affichage2(eltAafficher) { var eltAfficher = document.getElementById(eltAafficher); if (eltAfficher.style.display=="block") { eltAfficher.style.display="none"; } else { eltAfficher.style.display="block"; } } </script> </head> <body> <div id="en_tete"> <!-- banniere --> </div> <br /> <div id="corps"> <div class="image_corps_haut"> </div> <br /> <center> <img src="../images/ogamelinks_07.jpg" width="69" height="60" alt="ogamelinks_07"/> <img src="../images/ogamelinks_08.jpg" width="700" alt="titre1" value="compte1" onclick="affichage2('un');"/> <br /><br /> <div id="un" style="visibility:hidden"> <table border="2" width="600"> <thead> <tr> <th width="200">Nom</th> <th width="300">Description</th> <th width="100">Lien</th> </tr> </thead> <tbody> <tr> <td><center>Nom lien1</center></td> <td><center>Description lien1</center></td> <td><center>Lien1</center></td> </tr> <tr> <td><center>Nom lien2</center></td> <td><center>Description lien2</center></td> <td><center>Lien2</center></td> </tr> <tr> <td><center>Nom lien3</center></td> <td><center>Description lien3</center></td> <td><center>Lien3</center></td> </tr> </tbody> </table> </div> <br /><br /><br /> <img src="../images/ogamelinks_07.jpg" width="69" height="60" alt="ogamelinks_07"/> <img src="../images/ogamelinks_08.jpg" width="700" alt="titre1" value="compte1" onclick="affichage2('deux');"/> <br /><br /> <div id="deux" style="visibility:hidden"> <table border="2" width="600"> <thead> <tr> <th width="200">Nom</th> <th width="300">Description</th> <th width="100">Lien</th> </tr> </thead> <tbody> <tr> <td><center>Nom lien1</center></td> <td><center>Description lien1</center></td> <td><center>Lien1</center></td> </tr> <tr> <td><center>Nom lien2</center></td> <td><center>Description lien2</center></td> <td><center>Lien2</center></td> </tr> <tr> <td><center>Nom lien3</center></td> <td><center>Description lien3</center></td> <td><center>Lien3</center></td> </tr> </tbody> </table> <br><br><br> </div> <div class="image_corps_bas"> </div> </center> </div> </body> </html> |
|
|
|
|
|
#4 (permalink) |
|
Invité de passage
![]() Date d'inscription: avril 2007
Messages: 8
|
Désormais j'ai :
Code :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="screen" type="text/css" title="style" href="../css/style.css" /> <title>Ogame Links</title> <script language="JavaScript"> function affichage2(eltAafficher) { var eltAfficher = document.getElementById(eltAafficher); if (eltAfficher.style.display=="block") { eltAfficher.style.display="none"; } else { eltAfficher.style.display="block"; } } </script> </head> <body> <div id="en_tete"> <!-- banniere --> </div> <br /> <div id="corps"> <div class="image_corps_haut"> </div> <br /> <center> <img src="../images/ogamelinks_07.jpg" width="69" height="60" alt="ogamelinks_07"/> <img src="../images/ogamelinks_08.jpg" width="700" alt="titre1" value="compte1" onclick="affichage2('un');"/> <br /><br /> <div id="un" style="visibility:hidden"> <table border="2" width="600"> <thead> <tr> <th width="200">Nom</th> <th width="300">Description</th> <th width="100">Lien</th> </tr> </thead> <tbody> <tr> <td><center>Nom lien1</center></td> <td><center>Description lien1</center></td> <td><center>Lien1</center></td> </tr> <tr> <td><center>Nom lien2</center></td> <td><center>Description lien2</center></td> <td><center>Lien2</center></td> </tr> <tr> <td><center>Nom lien3</center></td> <td><center>Description lien3</center></td> <td><center>Lien3</center></td> </tr> </tbody> </table> </div> <br /><br /><br /> <img src="../images/ogamelinks_07.jpg" width="69" height="60" alt="ogamelinks_07"/> <img src="../images/ogamelinks_08.jpg" width="700" alt="titre1" value="compte1" onclick="affichage2('deux');"/> <br /><br /> <div id="deux" style="visibility:hidden"> <table border="2" width="600"> <thead> <tr> <th width="200">Nom</th> <th width="300">Description</th> <th width="100">Lien</th> </tr> </thead> <tbody> <tr> <td><center>Nom lien1</center></td> <td><center>Description lien1</center></td> <td><center>Lien1</center></td> </tr> <tr> <td><center>Nom lien2</center></td> <td><center>Description lien2</center></td> <td><center>Lien2</center></td> </tr> <tr> <td><center>Nom lien3</center></td> <td><center>Description lien3</center></td> <td><center>Lien3</center></td> </tr> </tbody> </table> <br><br><br> </div> <div class="image_corps_bas"> </div> </center> </div> </body> </html> ![]() Par contre le teste ne s'affiche plus :S Vous savez pourquoi? Je pensais peut-être à : Code :
<div id="un" style="visibility:hidden"> |
|
|
|
|
|
#6 (permalink) |
|
Invité de passage
![]() Date d'inscription: avril 2007
Messages: 8
|
Voila j'ai suivi tes conseils et j'ai modifié :
Code :
<script language="JavaScript"> function affichage2(eltAafficher) { var eltAfficher = document.getElementById(eltAafficher); if (eltAfficher.style.display=="block") { eltAfficher.style.display="none"; } else { eltAfficher.style.display="block"; } } </script> Merci pour votre aide |
|
|
|
|
![]() |
![]() |
||
affichage fonction onClick (résolu)
|
||
| Outils de la discussion | |
|
|