I create an HTML table dynamically, and apply some styles:
var tbl = document.createElement('table');
tbl.id = "CrewMemberTable";
document.getElementById("CrewMemberPanel").appendChild(tbl);
I then insert rows and cells in the table (just three in this example for brevity):
CrewRow = document.getElementById("CrewMemberTable").insertRow(-1);
CrewCell = CrewRow.insertCell(-1); CrewCell.innerHTML = "this text";
CrewCell = CrewRow.insertCell(-1); CrewCell.innerHTML = "some text";
CrewCell = CrewRow.insertCell(-1); CrewCell.innerHTML = "more text";
On this last cell, I apply a style, via javascript:
CrewCell = CrewRow.insertCell(-1); CrewCell.innerHTML = "more text";
CrewCell.style.backgroundColor = "GREEN";
Finally, I have this style in my .CSS stylesheet:
#CrewMemberTable tr:hover {
background-color: RED !important;
}
When I run it, strictly speaking, I guess nothing is wrong. It's doing what I asked it to do.
BUT - I want the hover to cover the entire row, but instead it only covers the first two cells, and the last cell, where the background color was assigned in javascript, it remains green. I want the entire row red.
Is this possible? And how?
<td>and then add that class, instead of the style, with your JavaScript?