-3

I want to create an HTML object in HTML and call it N number using JavaScript. For example this is my object that I want to create N times in html page using java script:

<div class="row">
  <div class="column" style="background-color:#aaa;">
    <h2>Column 1</h2>
    <p>Some text..</p>
  </div>
</div>
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • Welcome to Stack Overflow! Please take the [tour] and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) Do your research, [search](/help/searching) for related topics on SO, and give it a go. ***If*** you get stuck and can't get unstuck after doing more research and searching, post a [mcve] of your attempt and say specifically where you're stuck. People will be glad to help. Good luck! – T.J. Crowder Feb 24 '18 at 08:55
  • That's not an Object ... that's a fragment of HTML ... you can't CALL it ... you could `clone` it though – Jaromanda X Feb 24 '18 at 08:57
  • Possible duplicate of [Clone
    and change id](https://stackoverflow.com/questions/11985156/clone-div-and-change-id)
    – Stephen Kennedy Feb 28 '18 at 11:53

1 Answers1

-1
Go to see js dom 
Example 
eg:


<div id="div1">
<p id="p1">这是一个段落</p>
<p id="p2">这是另一个段落</p>
</div>

<script>
var para=document.createElement("p");
var node=document.createTextNode("这是新段落。");
para.appendChild(node);

var element=document.getElementById("div1");
element.appendChild(para);
</script>
kero99
  • 29
  • 5