<body> <table border="1"> <thead> <tr> <th>姓名</th> <th>性别</th> <th>年龄</th> </tr> </thead> <tbody class="content"> </tbody> </table> </body> <script> var stu = [{name: "张一", sex: "男", age: 18}, {name: "王平", sex: "男", age: 19}, {name: "张言", sex: "女", age: 20}] let myBody = document.querySelector('.content'); for (let i = 0; i < stu.length; i++) { myBody.innerHTML += ` <tr> <td>${stu[i].name}</td> <td>${stu[i].sex}</td> <td>${stu[i].age}</td> </tr> `; } </script>
表格渲染
猜你喜欢
转载自blog.csdn.net/qq_38796823/article/details/85148766
今日推荐
周排行