Ver Mensaje Individual
  #9 (permalink)  
Antiguo 17/09/2012, 14:50
Avatar de fjrueda
fjrueda
 
Fecha de Ingreso: marzo-2008
Ubicación: Bucaramanga
Mensajes: 313
Antigüedad: 16 años, 11 meses
Puntos: 35
Respuesta: como ocultar divs

Nobrogram.

Le pongo un ejemplo muy sencillo y basico y usted me dira si le sirve o no.

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. function demonone(quien)
  3. {
  4.     document.getElementById(quien).style.display="none";
  5.     if(quien=='p1')
  6.     {
  7.          document.getElementById('bhp2').disabled = true;
  8.          document.getElementById('bsp2').disabled = true;
  9.     }
  10. }
  11.  
  12. function demoblock(quien)
  13. {
  14.     document.getElementById(quien).style.display="block";
  15.     if(quien=='p1')
  16.     {
  17.         document.getElementById('bhp2').disabled = false;
  18.         document.getElementById('bsp2').disabled = false;
  19.     }
  20. }
  21. #p1
  22. {
  23.     background-color: blue;
  24.     color: #FFFFFF;
  25.     padding: 10px;
  26. }
  27.  
  28. #p2
  29. {
  30.     background-color: #FFFFFF;
  31.     width: 50%;
  32.     color: #000000;
  33. }
  34. </head>
  35. <div id="p1">
  36.     This is some father text.
  37.     <div id="p2">This is some son text.</div>
  38.     <p>...</p>
  39. </div>
  40. <input id="bhp1" type="button" onclick="demonone('p1')" value="Hide father text with display property" />
  41. <input id="bsp1" type="button" onclick="demoblock('p1')" value="Show father text with display property" />
  42. <input id="bhp2" type="button" onclick="demonone('p2')" value="Hide son text with display property" />
  43. <input id="bsp2" type="button" onclick="demoblock('p2')" value="Show son text with display property" />
  44. </body>
  45. </html>