把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> 

 

posted @ 2017-03-18 10:22  陈晓猛  阅读(1295)  评论(0编辑  收藏  举报