I'm trying to create a dynamic array-based header that the function receives, the structure I tried, and did not work, is as follows:
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 resolve this?