Click to See Complete Forum and Search --> : Changing background color


Webskater
10-20-2003, 04:16 AM
I am trying to get the background color of the first cell in a row to change when I mouseover any cell in the row.
This function ...

function showup()
{
var table = agequeue;
var rowNo = event.srcElement.parentElement.parentElement.rowIndex;
var colNo = event.srcElement.parentElement.cellIndex;
table.rows[rowNo].cells[0].bgcolor = 'navy';
}

returns the correct reference to the cell I want to change but the background color won't change. I have tried

table.rows[rowNo].cells[0].style.background-color = 'navy'

but nothing happens.
Can anyone tell me how to do this please. Thanks.

gil davis
10-20-2003, 07:53 AM
Originally posted by Webskater
I am trying to get the background color of the first cell in a row ...
table.rows[rowNo].cells[0].style.background-color = 'navy'
It should be
table.rows[rowNo].cells[0].style.backgroundColor = 'navy'
To change a CSS attribute to a JS attribute, you drop the "-" and capitalize the character that follows the "-".

Webskater
10-21-2003, 10:54 AM
Thanks very much for your answer. Suddenly lots of things I did not understand now make sense.