Please refer to the variable "TEST", how to that it become innerHTML and not like plain text when onload?
<!DOCTYPE html>
<head>
<title>Sum Table Column</title>
<script>
window.onload=function() {
var TEST = "<font color='#ff0000'>Apple</font>";
var values = new Array(3);
values[0] = [123.45, TEST, true] ;
values[1] = [65, "banana", false];
values[2] = [1034.99, "cherry", false];
var mixed = document.getElementById("mixed");
// IE7 only supports appending rows to tbody
var tbody = document.createElement("tbody");
// for each outer array row
for (var i = 0 ; i < values.length; i++) {
var tr = document.createElement("tr");
// for each inner array cell
// create td then text, append
for (var j = 0; j < values[i].length; j++) {
var td = document.createElement("td");
var txt = document.createTextNode(values[i][j]);
td.appendChild(txt);
tr.appendChild(td);
}
// append row to table
// IE7 requires append row to tbody, append tbody to table
tbody.appendChild(tr);
mixed.appendChild(tbody);
}
}
</script>
</head>
<body>
<table id="mixed">
<tr><th>Value One</th><th>Value two</th><th>Value three</th></tr>
</table>
</body>
Please refer to the variable "TEST", how to that it become innerHTML and not like plain text when onload?
row = table.insertRow(), which appends the row as the last row in the table and assigns a reference to row. See MDN insertRow. Also, it would be better to implement highlighting by applying a class so that you just mess with the CSS to change how the text looks, rather than having to mess with javascript when you want it, say, green instead of red. The font element was deprecated in HTML 4 and is removed in HTML 5.