The below function is used to create multiple divscontent division elements (i.e. <div>) inside a containing div<div>. The function is working correctly and is as expected, I just feel the quality of the code itself is a bit poor.
Therefore, can the following function be, in any way, simplified or improved?
generate(chartData) {
var container = document.createElement("div");
$(container).attr("class", "container2");
var myNode = document.getElementById(chartData.bindto.replace("#", "")).appendChild(container);
for(var i = 0; i < 10; i++) {
var div = document.createElement('div');
$(div).attr("class", "block");
var span = document.createElement('span');
var text = "Hello World!";
span.append(text);
div.append(span);
myNode.append(div);
}
}