如果我已将表单中的所有字段保存到数组中,
var reqfield = document.getElementsByClassName("req");
如何根据所述数组设置单个字段的 css 样式。
document.getElementById("myform")reqfield[1].style.backgroundColor = "red";
最佳答案
您已经将项目存储在数组中。应该只是这样
reqfield[1].style.backgroundColor = "red";
关于javascript - JS - 从数组设置表单输入字段的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37234689/