index.html 986 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. </body>
  11. <script>
  12. let table = document.createElement("table");
  13. for (let i = 1; i < 10; i++){
  14. let tr = document.createElement("tr");
  15. for (let a = 1; a < 10; a++){
  16. let td = document.createElement("td");
  17. td.innerText = a * i;
  18. td.style.border = '2px solid #d3d3d3'
  19. td.style.padding = '20px'
  20. td.style.fontSize = '20px'
  21. td.style.textAlign = 'center'
  22. tr.appendChild(td);
  23. td.onmouseover = function(){
  24. this.style.backgroundColor = "red"
  25. }
  26. td.onmouseout = function () {
  27. this.style.backgroundColor = 'white'
  28. }
  29. }
  30. table.appendChild(tr)
  31. }
  32. document.body.appendChild(table);
  33. </script>
  34. </html>