Programmatically using onmouseover for an element added with appendChild
-
27-09-2019 - |
Question
I am using this code to add a row to a table usign js:
var tbody = document.getElementById('tableID').getElementsByTagName('tbody')[0];
var row = document.createElement("TR");
tbody.appendChild(row);
I want to use onmouseover on that TR to make it change the background color, how can I do that?
Solution
row.onmouseover = function() { this.style.backgroundColor = "Green"; };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow