how to create table using dom

Solutions on MaxInterview for how to create table using dom by the best coders in the world

showing results for - "how to create table using dom"
Luciana
27 Oct 2017
1function render(){
2for (let i = 0; i < allMovie.length; i++) {
3    tr = document.createElement('tr');
4    tr.setAttribute("class", "mainTR");
5    table.appendChild(tr);
6
7    var td1 = document.createElement('td');
8    td1.textContent = allMovie[i].MovieName11;
9    td1.setAttribute("class", "td1");
10    tr.appendChild(td1);
11    
12    var td2 = document.createElement('td');
13    td2.textContent = allMovie[i].selectPlatform11;
14    td2.setAttribute("class", "td2");
15    tr.appendChild(td2);
16
17    var td3 = document.createElement('td');
18    td3.textContent = allMovie[i].randomRate;
19    td3.setAttribute("class", "td3");
20    tr.appendChild(td3);
21
22    var td4 = document.createElement('td');
23    td4.textContent = allMovie[i].monthlyPay11;
24    td4.setAttribute("class", "td4");
25    tr.appendChild(td4);
26
27   var td5 = document.createElement('td');
28    td5.setAttribute("id", "td5");
29    td5.innerHTML = `<button onclick=remove(this.parentElement)> X </button>`
30    tr.appendChild(td5);
31}
32}
33