Also habe ich meine Tabelle und läuft, aber ich bin nicht in der Lage, einen gültigen "malito" Link zu meinem Tisch hinzufügen, und es gibt keine guten Beispiele, die ich kann finden. Ich habe versucht, etwas wieSo fügen Sie einen Link zu einer Tabelle via JS-Datei
"<td>" + <a href = "users[i].email"> + </a> + "</td>" +
aber es funktioniert nicht =.
var users = [
{first_name: "Kaitlin", last_name: "Burns", age: 23, email: "[email protected]"},
{first_name: "Joshua", last_name: "Feir", age: 31, email: "[email protected]"},
{first_name: "Stephen", last_name: "Shaw", age: 28, email: "[email protected]"},
{first_name: "Timothy", last_name: "McAlpine", age: 37, email: "[email protected]"},
{first_name: "Sarah", last_name: "Connor", age: 19, email: "[email protected]"}
];
window.onload = function()
{
var tableContainer = document.querySelector("#outputTable");
var table = "";
for (var i = 0; i < users.length; i++)
{
table += "<tr>" +
"<td>" + users[i].first_name + "</td>" +
"<td>" + users[i].last_name + "</td>" +
"<td>" + users[i].age + "</td>" +
//Email link here
"</tr>";
}
tableContainer.innerHTML += table;
};
HTML FILE
<h3> Information </h3>
<head>
<script src = "js/table.js"></script>
</head>
<body>
<table id = "outputTable" border = "1">
<thead style = "background-color: orangered;">
<tr>
<th> First Name </th>
<th> Last Name </th>
<th> Age </th>
<th> Email </th>
</tr>
</table>
</body>
Dies ist, wie mein Tisch
Information
First Name Last Name Age Email
Kaitlin Burns 23
Joshua Feir 31
Stephen Shaw 28
Timothy McAlpine 37
Sarah Connor 19
Es behoben, aber nichts ändert sich –