<script>
for(var numCols = 1; numCols <= 12; numCols++){
    document.write(
                        "<div class='row'>" +
                        "<div class='well text-center col-lg-" + [numCols] + "'>" + ".col-lg-" + [numCols] + "</div>" +
                        "</div>";
                    );
}
</script>

我知道这里有document.write/document.writeln但是我有这个脚本,我不知道怎么了。我试着想象一下Bootstrap的

最佳答案

删除最后一个</div>

<script>
for(var numCols = 1; numCols <= 12; numCols++){
    document.write(
                        "<div class='row'>" +
                        "<div class='well text-center col-lg-" + [numCols] + "'>" + ".col-lg-" + [numCols] + "</div>" +
                        "</div>"
                    );
}
</script>

10-07 14:34