Say I have three buttons in a row, with the end one being a 'deadly' button. Is there a way I can click on button 1, and it would tell me that it's 2 elements away from the 'deadly' button? Or click on button 2, which would tell me it's once space away from number 3, the 'deadly' button.
I'm not sure I've explained this very well, so I'll link an example of the setup.
I'm hoping do something similar to the Minesweeper way of detecting the 'mines'.
HTML
<table>
<tr>
<td><button id="1">Button 1</button></td>
<td><button id="2">Button 2</button></td>
<td><button id="3">Button 3</button></td>
</tr>
<tr>
<td><button id="4">Button 4</button></td>
<td><button id="deadly">Button 5</button></td>
<td><button id="6">Button 6</button></td>
</tr>
<tr>
<td><button id="7">Button 7</button></td>
<td><button id="8">Button 8</button></td>
<td><button id="9">Button 9</button></td>
</tr>
</table>
I'm currently using JQuery, so any solution that uses it will still work for me.