小编Man*_*ald的帖子

使用Javascript创建表

我有一个JavaScript函数,它创建一个包含3行2个单元格的表.

谁能告诉我如何使用我的功能创建下表(我需要根据我的情况这样做)?

这是我的javascript和html代码,如下所示:

function tableCreate() {
  //body reference 
  var body = document.getElementsByTagName("body")[0];

  // create elements <table> and a <tbody>
  var tbl = document.createElement("table");
  var tblBody = document.createElement("tbody");

  // cells creation
  for (var j = 0; j <= 2; j++) {
    // table row creation
    var row = document.createElement("tr");

    for (var i = 0; i < 2; i++) {
      // create element <td> and text node 
      //Make text node the contents of <td> element
      // put <td> at end of the …
Run Code Online (Sandbox Code Playgroud)

javascript html-table

88
推荐指数
5
解决办法
44万
查看次数

标签 统计

html-table ×1

javascript ×1