main.js 608 B

1234567891011121314151617181920
  1. var table = document.createElement("table");
  2. table.setAttribute("cellpadding","15");
  3. table.setAttribute("border", "1");
  4. table.style.borderCollapse = "collapse";
  5. table.style.borderColor = "#ccc";
  6. document.body.appendChild(table);
  7. for (var i = 0; i < 9; i++) {
  8. table.appendChild(document.createElement("tr"));
  9. for (var j = 0; j < 9; j++) {
  10. table.children[i].appendChild(document.createElement("td"));
  11. table.children[i].children[j].innerHTML = (i + 1) * (j + 1);
  12. }
  13. }
  14. var c = table.querySelectorAll("tr:nth-child(2n)");
  15. for (var i = 0; i < c.length; i++) {
  16. c[i].style.backgroundColor = "#efefef";
  17. }