I want to style my table I created with javascript like:
var table = document.createElement('TABLE');
var thead = document.createElement('THEAD');
table.appendChild(thead);
var trhead = document.createElement('TR');
thead.appendChild(trhead);
var headers = new Array("Date", "Event", "Artist");
for (var x = 0; x < 3; x++) {
var tdhead = document.createElement('TD');
bold = document.createElement('strong'),
textnode = document.createTextNode(headers[x]);
bold.appendChild(textnode);
tdhead.appendChild(bold);
tdhead.style.color = "#212529";
tdhead.style.fontWeight="bold";
trhead.appendChild(tdhead);
}
var tableBody = document.createElement('TBODY');
table.appendChild(tableBody);
for (i=0;i<total;i++) {
var tr = document.createElement('TR');
tableBody.appendChild(tr);
var dategig = json.data[i].date.value;
var dategig = dategig.split('T')[0];
var artist = json.data[i].artist.name
var event = json.data[i].eventName
var arr = new Array(dategig, event, artist);
for (var j = 0; j < 3; j++) {
var td = document.createElement('TD');
textnode = document.createTextNode(arr[j]);
td.appendChild(textnode);
td.style.color = "#212529";
tr.appendChild(td);
}
}
myTableDiv.appendChild(table);
As you can see I already can assign a color to the cells. Now I want to add a border-bottom to the TR element:
tr.style.border= "1pt";
But that doesn't change anything on the table.. also "border-bottom" is not recognized as an style attribute, why?
borderBottomand notborder-bottom. See this info