JSFiddle - React, Tailwind, and code Playground
HTML
<table onclick="tableHandler(this)">
<tr>
<td width="100%" colspan="2" id="showRowContol">
v
</td>
</tr>
<tr>
<td width="100%">
Первая
</td>
<td id="hideRowContol">
x
</td>
</tr>
<tr>
<td width="100%">
Вторая
</td>
<td id="hideRowContol">
x
</td>
</tr>
<tr>
<td width="100%">
Третья
</td>
<td id="hideRowContol">
x
</td>
</tr>
<tr>
<td width="100%">
Четвертая
</td>
<td id="hideRowContol">
x
</td>
</tr>
<tr>
<td width="100%">
Пятая
</td>
<td id="hideRowContol">
x
</td>
</tr>
</table>
CSS
#hideRowContol{
cursor: pointer;
font-size: 2em;
color: #ff0000;
}
#showRowContol{
color:#00ff00;
font-size: 3em;
}
table {
border: 1px #539450 solid;
width:50%;
}
td{
border: 1px #aaaaff solid;
}
JavaScript
//Прячем определенную строку
function hideRow(control) {
control.parentElement.style.display = (control.parentElement.style.display == "" ? "none" : "");
}
//функция показывает все строки
function showAllRow(control) {
for (var i = 0; i < control.rows.length; i++) {
control.rows[i].style.display = "";
}
}
//функция по выбору действия
function tableHandler(table) {
var control = event.srcElement;
switch (control.id) {
case "showRowContol":
showAllRow(table);
break;
case "hideRowContol":
hideRow(control);
break;
}
}