Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<table>
    <thead>
        <tr>
            <th>ÍTEM</th>
            <th>OPCIONES</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Ítem 1</td>
            <td>
                <button onclick = "mostrarOcultar('id_1')">Mostrar/Ocultar</button>
            </td>
        </tr>
        <tr class = "oculta" id = "id_1">
            <td colspan = "2">
                <table>
                    <thead>
                        <tr>
                            <th>SUB-ÍTEM</th>
                            <th>OPCIONES</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>Sub-ítem 1</td>
                            <td>
                                <button>Editar</button>
                            </td>
                        </tr>
                        <tr>
                            <td>Sub-ítem 2</td>
                            <td>
                                <button>Editar</button>
                            </td>
                        </tr>    
                        <tr>
                            <td>Sub-ítem 3</td>
                            <td>
                                <button>Editar</button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <td>Ítem 2</td>
            <td>
                <button onclick = "mostrarOcultar('id_2')">Mostrar/Ocultar</button>
            </td>
        </tr>
        <tr class = "oculta" id = "id_2">
            <td colspan = "2">
                <table>
                    <thead>
                        <tr>
                            <th>SUB-ÍTEM</th>
                            <th>OPCIONES</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>Sub-ítem 4</td>
                            <td>
                                <button>Editar</button>
                            </td>
                        </tr>
                        <tr>
                            <td>Sub-ítem 5</td>
                            <td>
                                <button>Editar</button>
                            </td>
                        </tr>
                        <tr>
                            <td>Sub-ítem 6</td>
                            <td>
                                <button>Editar</button>
                            </td>
                        </tr>    
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
</body>
</html>
 
table, table *{
    border: .1rem solid;
    text-align: center;
}
table{
    width: 50%;
}
.oculta table{
    width: 100%;
}
.oculta{
    display: none;
}
 
function mostrarOcultar(id){
    var fila = document.getElementById(id);
    if (getComputedStyle(fila).display == "none"){
        fila.style.display = "table-row";
    }
    else{
        fila.style.display = "none";
    }
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers