我需要显示一个包含 100 多个足球运动员号码、姓名、体重、年龄和身高的列表。我宁愿不复制/粘贴我设置的完全相同的 div 并手动更改它们。我想知道是否有办法在我已经编码的 html 布局中显示每组数据?我在谷歌上唯一能找到的是 Javascript 生成它自己的表。这是一个例子:
这是数组:
var playerArray = [
["#25","Player1", "Weight1", "Height1", "Age1", "Position1"],
["#99","Player2", "Weight2", "Height2", "Age2", "Position2"],
["#77","Player3", "Weight3", "Height3", "Age3", "Position3"],
["#63","Player4", "Weight4", "Height4", "Age4", "Position4"],
["#43","Player5", "Weight5", "Height5", "Age5", "Position5"],
];
这是我希望显示数据的html:
<div class="rosterlist">
<div class="p_name">[[NUMBER]] <span class="light_text2">/ [[NAME]]</span></div>
<div class="roster_line_2"><div class="p_pos">[[POSITION]]</div><div class="p_height">[[HEIGHT]]</div><div class="p_grade">[[AGE]]</div><div class="p_weight">[[WEIGHT]]</div></div>
</div>
如果不可能,请告诉我,我会开始复制和粘贴:(