0
I’m trying to create a dynamic header based on an array that the function receives, the structure I tried, and it didn’t work, is the following:
function createDynamicHeader(columns) {
var table = document.querySelector('#table_teste');
var header = table.createTHead();
header.createElement('tr');
for (var i = 0; i < columns.length; i++) {
var header_row = header.createElement('th');
header_row.innerHTML(columns[i]);
}
}
HTML:
<table id="table_teste" class="table table-bordered"></table>
How can I fix this?