I'm using JavaScript to highlight a row or column in a table.
I have created a CSS class that changes the background colour to a light blue and I apply this class to the cells in the selected row/column.
It works great most of the time but sometimes the cell may have an inline style sets background colour to yellow. This, of course, overwrites the background colour in the class that is being used to highlight the cell.
(Also, all of the cells contain at least one hyperlink and if the cell's background colour is set to yellow, this hyperlink's background colour is also set to yellow using an inline style)
When applying the class to the cell I have attempted to remove the background color for the cell (and hyperlink) but this does not appear to work.
Could someone please point out what I'm doing wrong:
Expand|Select|Wrap|Line Numbers
- function SelectColumn(colIndex)
- { Deselect(); //<----deselects any rows/columns selected
- var gridView = document.getElementById('myGridTable');
- var rows = gridView.getElementsByTagName('tr');
- for(i=0; i < rows.length; i++)
- {
- var cells = rows[i].getElementsByTagName('td');
- if(colIndex<cells.length)
- {
- cells[colIndex].className = cells[colIndex].className +' selectedRowOrColumn';
- cells[colIndex].style.backgroundcolor = '';
- var links = cells[colIndex].getElementsByTagName('a');
- for(linkIndex = 0; linkIndex < links.length; linkIndex++)
- {
- links[linkIndex].style.backgroundcolor = '';
- }
- }
- }
- //......
- }
Thanks
-Frinny