Estoy creando una tabla que necesito ocultar o mostrar el contenido en forma escalada. Ya lo logré de esta forma, pero me gustaría saber si hay una mejor
Código HTML:
Pulsen las primeras tres columnas y verán lo que hace, pero me gustaría saber si se puede hacer algo mejor que eso. Ver original
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <style> td{ cursor: pointer; border: 1px solid #000; } .content td{ border: none; } </style> <script type="text/javascript"> function hideUnhideElement(id){ var thisElement = document.getElementById(id).style; if(thisElement.display == 'none'){ thisElement.display = 'block'; } else{ thisElement.display = 'none'; } } </script> </head> <body> <table> <tr> <td id="subCategoria[0]"> <table> <tr> <td id="subSubCategoria[0]"> <table> <tr> <td id="contenido[0]"> <table class="content"> <tr> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td id="subCategoria[1]"> <table> <tr> <td id="subSubCategoria[1]"> <table> <tr> <td id="contenido[1]"> <table class="content"> <tr> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td id="subCategoria[2]"> <table> <tr> <td id="subSubCategoria[2]"> <table> <tr> <td id="contenido[2]"> <table class="content"> <tr> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body> </html>
Si alguien entiende que hay una mejor forma que no dude en decirlo
o me lo parece...
?...
veras, lo digo porque tanto la propuesta de cronos como el arreglo que hiciste, no funciona en chrome/firefox. la explicación es bien sencilla. iexplorer no genera los nodos tipo Text cuando consiste de caracteres en blanco (whitespace) pero el resto de los navegadores los preserva. primero una ilustracion y luego los detalles.
. La verdad es que le hago al table un display none no al td.

