Creating dynamic tables using javascript, given rows and column in textboxes

后端 未结 3 1259
梦如初夏
梦如初夏 2021-01-07 00:22

I am back with a problem again (please cooperate with my silly questions, i am very new to JavaScript). I am trying for understanding the concept of dynamic tables in JavaS

3条回答
  •  庸人自扰
    2021-01-07 00:44

    here's another solution using innerHTML

    
    

    after that, just add the result to whatever element you want using innerHTML, for example, if you have:

    then you can add the table to the element (inside any js function) like this:

    var targetElement = document.getElementById('myElement');
    targetElement.innerHTML = createTable();
    

    otherwise, you can just delete the line:

    return resultTable;
    

    and add the table to the element directly inside the function, like this:

    var target = document.getElementById('myElement');
    target.innerHTML=resultTable;
    

提交回复
热议问题