index.html 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <script src="main.js"></script>
  8. </head>
  9. <body>
  10. <style>
  11. .table {
  12. padding: 15px;
  13. border: 1px solid #e9c6c6;
  14. border-radius: 4px;
  15. color: #4e4339;
  16. background-color: #f8ffcd;
  17. text-align: center;
  18. }
  19. .td{
  20. height: 25px;
  21. width: 25px;
  22. text-align: center;
  23. }
  24. </style>
  25. <script>
  26. let table = document.createElement('table');
  27. table.setAttribute('border','1')
  28. table.className = "table";
  29. document.body.append(table)
  30. table.setAttribute("align", "center");
  31. for(let y = 0; y<10;y++){
  32. let tr = document.createElement('tr')
  33. table.append(tr)
  34. for(let x = 0; x<10;x++){
  35. let td = document.createElement('td')
  36. table.append(td)
  37. let temp = x*y;
  38. if(x===0){
  39. temp = y
  40. }
  41. else if( y===0){
  42. temp = x
  43. }
  44. td.innerText = temp
  45. td.className = "td";
  46. // td.onmousemove = function () {
  47. // this.style.background = "yellow";
  48. // }
  49. // td.onmouseout = function () {
  50. // this.style.background = "none";
  51. // }
  52. // td.onmousemove = function () {
  53. // for (let item of this.parentElement.children) {
  54. // item.style.background = "yellowgreen";
  55. // }
  56. // for (let item of this.parentElement.parentElement.children) {
  57. // for (let item2 of item.children) {
  58. // if (item2.cellIndex === this.cellIndex) {
  59. // item2.style.background = "yellowgreen";
  60. // }
  61. // }
  62. // }
  63. // }
  64. // td.onmouseout = function () {
  65. // for (let item of this.parentElement.children) {
  66. // item.style.background = "none";
  67. // }
  68. // for (let item of this.parentElement.parentElement.children) {
  69. // for (let item2 of item.children) {
  70. // if (item2.cellIndex === this.cellIndex) {
  71. // item2.style.background = "none";
  72. // }
  73. // }
  74. // }
  75. // }
  76. //ХЗ ЧЕГО НЕ РАБОТАЕТ
  77. }
  78. }
  79. </script>
  80. </body>
  81. </html>