hw10_15_DOM highlight cell.html 655 B

1234567891011121314151617181920
  1. <head>DOM highlight cell</head>
  2. <body>
  3. <script>
  4. let table = document.createElement("table");
  5. for (let i = 1; i <= 9; i++) {
  6. let row = document.createElement("tr");
  7. table.append(row);
  8. for (let j = 1; j <= 9; j++) {
  9. let column = document.createElement("td");
  10. column.innerText = i * j;
  11. row.append(column);
  12. column.onmouseover = () => column.style.backgroundColor = "grey";
  13. column.onmouseout = () => column.style.backgroundColor = "white";
  14. }
  15. }
  16. document.body.append(table);
  17. </script>
  18. </body>