当前位置:网站首页>Dynamically generate tables

Dynamically generate tables

2022-07-07 05:03:00 Hugging spinner

Create student data

Because the student data inside is dynamic , We need to s Dynamic generation . Here we simulate the data , Define your own data .

Because there are many, many data in it , So we use the form of array to store , The element in each array is an object

  Create lines

Because the student data inside is dynamic , We need to js Dynamic generation . Here we simulate the data , Define your own data . We store data in the form of objects .
All the data is put in tbody Inside the line .
Because it can do a lot , We need to create multiple rows in a loop ( How many people )

Create cells

There are many cells in each row ( Corresponding to the data inside ), We also continue to use loops to create multiple cells , And store the data in it ( double for loop )

Cell filling data

  Be careful :

for(var k in obj) {

  k What you get is the attribute name

  obj[k] The result is the attribute value

}

  Create or delete cells

The last column of cells is delete , You need to create cells separately .

  Add delete operation

  Be careful : Delete is to delete after all rows and cells are created , So we have to put for Below the loop

Here are all the codes for dynamically generating tables

 

原网站

版权声明
本文为[Hugging spinner]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207062236520930.html