I want to select a cell range in an HTML table and using Javascript to change the background color of the selected cells. Is there an event to get all ids of the selected cells?
I tried this code:
function getSelectedCells()
{
selObj = window.getSelection();
alert(selObj);
}
And it printed out the cell content of the selected cells. Does anyone know how i can use this to get the id of the selected cells?
I will try your approach. I found a solution myself but it is far from pretty and only because I know how the ids of the cells are structured. Here is the code but it only works sometimes. I guess the regular expression is a little buggy. I use this to avoid changing the background from the wrong cells: