In my current project I have a table contained within a div that has 10 cells positioned horizontally. This is done using the following code below...
<div id="dashboard">
<table>
<tr>
<td><div id="cell1"></div></td>
<td><div id="cell2"></div></td>
<td><div id="cell3"></div></td>
<td><div id="cell4"></div></td>
<td><div id="cell5"></div></td>
<td><div id="cell6"></div></td>
<td><div id="cell7"></div></td>
<td><div id="cell8"></div></td>
<td><div id="cell9"></div></td>
<td><div id="cell10"></div></td>
</tr>
</table>
</div>
I already have code saying that if a user clicks on a button that corresponds to a cell in the table, the cell will highlight yellow. Since the table's width is larger than the horizontal width of the page's container, I had to set the div table overflow property to auto. How can I make it so that if the user clicks a button for a specific cell that is not in view or only has some part of the cell in view, the table will auto scroll horizontally (left or right depending on the cell's location and the current view) to that specific cell.
Is there a JavaScript solution that would allow me to do this?