-3

I want to create multiple boxes with background and border with same pattern, So I just have to create boxes nth time or is there any formula which use that regular expression and repeat the same code in html.I want to append child with parent class box.

<div style="border: 1px solid gray;background-color: black;width: 10px;height: 10px "></div>

1 Answers1

0

What do you mean by regex to repeat HTML? You can use JavaScript to repeatedly insert HTML into the DOM

const div = document.createElement("div");
div.classList.add("boxDiv");
const HTML = Array.from(Array(10).keys()).map(i => div.cloneNode().outerHTML).join("")
document.querySelector(".box").innerHTML += HTML
.boxDiv { border: 1px solid gray;background-color: black;width: 10px;height: 10px }
<div class="box">
</div>
mplungjan
  • 134,906
  • 25
  • 152
  • 209