When I use .getAttribute()
instead of .value
. It assigns null to the local variable value
instead of the string.
for(let el of document.querySelectorAll("input,select"))
{
// this works
let value = el.value;
if(el.classList.contains("foo") == true)
{
// this returns null
value = el.getAttribute("value");
}
settings[el.name] = value;
}
Any ideas why .getAttribute()
is returning null instead of the value?
This is inside a vue component, not sure if that makes a difference.