把js生成的内容放入网页原有的div上
<script> var num=24; var cols=5; //5列 var rows=(num/5); var no = 1; var htmlstr="<table style='position:absolute;top:9%;left:10%; border-radius:12px;border:10px solid RGB(221,183,132);'>"; for(i=1;i<=rows;i++){ htmlstr+="<tr>"; for(j=1;j<=cols;j++){ no=(i*5)+j; htmlstr+="<td ><div id='player'><div style='width:103px;height:80px;'></div><span style='margin-left:19px;'>"+no+"号玩家</span></div></td>"; } htmlstr+="</tr>"; } for(i=1;i<=(num%5);i++){ htmlstr+="<td ><div id='player'><div style='width:103px;height:80px;'></div><span style='margin-left:19px;'>"+(no+i) +"号玩家</span></div></td>"; } for(i=1;i<=(cols-(num%5));i++){ htmlstr+="<td ><div id='noplayer'></div></td>"; } htmlstr+="</table>"; //document.write(htmlstr); document.getElementById("roombodytwo").innerHTML = htmlstr; </script>
声明 欢迎转载,但请保留文章原始出处:) 博客园:https://www.cnblogs.com/chenxiaomeng/
如出现转载未声明 将追究法律责任~谢谢合作