用JavaScript求下图的格式的星星,要求要连方框又实现

img


<html>
<body>

<table id="table" border="1" cellpadding="0" cellspacing="0" bordercolor="blue">
 
</table>
  <script>
        var table = document.getElementById("table")
      var x=9,y=19;
      var start=Math.ceil(y/2);
      for(var i=0;i<x;i++){
        var tr = document.createElement("tr");
        for(var j=0;j<y;j++) {
          var td = document.createElement("td");
          if(j+1>=start-i&&j+1<=start+i)td.className ="five-star";
          td.style.width="30";
          td.style.height="30";
          td.style.fontSize="18";
          td.style.color="red";
          td.style.textAlign="center";
          tr.appendChild(td)
        }
        table.appendChild(tr)
      }
  </script>
</body>
<style type="text/css">
  .five-star:before {
    content: "\2605";
 }
</style>
</html>

img