I cannot set the list
property of an <input>
element. sel.list = id
is not working in my code.
var sel = document.createElement("input");
sel.type = "text";
sel.id = "inputSelectName";
sel.list = "inputNamesList"; // Does not work.
//sel.setAttribute("list", "inputNamesList"); // Works
sel.name = "name"; // FIXME: We should reconsider the name name...
frm.appendChild(sel);
var datl = document.createElement("datalist");
datl.id = "inputNamesList";
// Populating the dataList
frm.appendChild(datl);
Of course, this doesn't work because the list
attribute is not the list = {id for datalist}
that I want. The only way to make this work is with the setAttribute
method.
How can I solve this without using the setter, but by changing the attribute directly?
When I look in the developer tools, I see that setAttribute("list", id)
is not setting the list
attribute.
input
. – SleetsetAttribute
? – Corenecoreopsis