So I'm making a javascript file that uses a loop to make the times tables 1 to 12, but I use css to make a neat feel by making any element with the class of timetable float to the right. However the divs which seperate each time table and have a class of timetable do not have any children. Im trying to make the p elements which hold one time table be the children of the divs. Here's my code:
var math = document.getElementById("maths");
for (var num = 1; num <= 12; num++) {
math.innerHTML += "<div class=\"timetable\">";
for (var currentMath = 1; currentMath <= 12; currentMath++) {
math.innerHTML += "<p>" + num + " x " + currentMath + " = " + (num * currentMath) + "
</p>";
}
math.innerHTML += "</div>";
}
Expected HTML:
<div class="timetable"><p>1 x 1 = 1</p>....</div>
HTML:
<div class="timetable"></div><p>1x1 = 1</p>...
Can anyone help me?