📌  相关文章
📜  无法读取未定义的属性“classList” - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:21.678000             🧑  作者: Mango

代码示例1
It means that document.getElementById("lastName") is returning undefined and you're trying to call classList on undefined itself.

In your HTML input has the attribute name which equals lastName but there is no actual id="lastname"

Either add the attribute id to your input or change getElementById to getElementsByName.

Note that getElementsByName doesn't return a single item.