a
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Hier den Code ergaenzen
|
||||
// (Event-Handling fuer Hinzufuegen-Button, DOM-Manipulation fuer Tabelle)
|
||||
const input = document.querySelector("p > input");
|
||||
const tbody = document.getElementsByTagName("tbody")[0];
|
||||
const button = document.getElementsByTagName("button")[0];
|
||||
button.onclick = createCheckbox;
|
||||
function createCheckbox() {
|
||||
let value = input.value;
|
||||
let tr = document.createElement("tr");
|
||||
let td = document.createElement("td");
|
||||
let text = document.createTextNode(value);
|
||||
let tdCheck = document.createElement("td");
|
||||
let checkbox = document.createElement("input");
|
||||
checkbox.type = "checkbox";
|
||||
checkbox.setAttribute("onclick","toggleTextDecoration(this)");
|
||||
|
||||
td.append(text);
|
||||
tdCheck.append(checkbox);
|
||||
tr.append(tdCheck);
|
||||
tr.append(td)
|
||||
|
||||
tbody.append(tr);
|
||||
}
|
||||
function toggleTextDecoration(checkbox){
|
||||
const td = checkbox.parentElement.nextElementSibling;
|
||||
td.style.textDecoration = checkbox.checked ? "line-through" : "none";
|
||||
}
|
||||
Reference in New Issue
Block a user