use setAttribute

This commit is contained in:
Arthur Lu 2022-12-19 18:12:39 -08:00
parent ca2633fb79
commit 06aa9ac47e

View File

@ -23,7 +23,8 @@ function addFormLine (id, labelAttr, inputAttr) {
let label = document.createElement("label"); let label = document.createElement("label");
label.for = id; label.for = id;
for (let k in labelAttr) { for (let k in labelAttr) {
label.k = labelAttr.k; label.setAttribute(k, labelAttr[k])
label[k] = labelAttr.k;
} }
labelWrapperDiv.append(label); labelWrapperDiv.append(label);
let labelContainer = document.querySelector("#labels"); let labelContainer = document.querySelector("#labels");
@ -34,7 +35,7 @@ function addFormLine (id, labelAttr, inputAttr) {
input.id = id; input.id = id;
input.name = id; input.name = id;
for (let k in inputAttr) { for (let k in inputAttr) {
input.k = inputAttr.k; input.setAttribute(k, inputAttr[k])
} }
inputWrapperDiv.append(input); inputWrapperDiv.append(input);
let inputContainer = document.querySelector("#inputs"); let inputContainer = document.querySelector("#inputs");