HTML how to automate the creation of/programmatically create divs?
- by bernlim
I have a div grid like this:
<div id="MainDiv" style="border:1px solid black; width:162px; height:160px;">
<div id="Column1" style="float:left">
<div id="sq1" style="width:40px; height:40px;">
</div>
<div id="sq2" style="width:40px; height:40px;">
</div>
<div id="sq3" style="width:40px; height:40px;">
</div>
<div id="sq4" style="width:40px; height:40px;">
</div>
</div>
<div id="Column2" style="float:left">
<div id="sq5" style="width:40px; height:40px;">
</div>
<div id="sq6" style="width:40px; height:40px;">
</div>
<div id="sq7" style="width:40px; height:40px;">
</div>
<div id="sq8" style="width:40px; height:40px;">
</div>
</div>
<div id="Column3" style="float:left">
<div id="sq9" style="width:40px; height:40px;">
</div>
<div id="sq10" style="width:40px; height:40px;">
</div>
<div id="sq11" style="width:40px; height:40px;">
</div>
<div id="sq12" style="width:40px; height:40px;">
</div>
</div>
How do I write just a few lines of code to automate the entire process?