Good. I want from .elemento_seleccionado
:
<table border="1">
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Iz/Ar</td>
<td class='arriba'>Arriba</td>
<td>De/Ar</td>
</tr>
<tr>
<td>Izquierda</td>
<td class='elemento_seleccionado>Seleccion</td>
<td>Derecha</td>
</tr>
<tr>
<td>Iz/Aba</td>
<td>Abajo</td>
<td>De/Aba</td>
</tr>
</tbody>
</table>
Being able to select your:
Element Up
Element Below
diagonals
So far I have been able to make the selection of:
Left
$(".selected_item").prev().css("background","cyan");
Right
$(".selected_item").next().css("background","orange");
You can pop out the cells of the current row and get the index of the selected cell via the
index
. From there you can calculate the indices of the cells to select in the previous and next rows.This example selects the cells around the cell that is clicked:
In the following way you can select all the positions, delete the ones you don't need:
EDITED
For it to make the selection it does not matter how many columns or rows it has