📅  最后修改于: 2022-03-11 15:00:24.848000             🧑  作者: Mango
const setEventListeners = (formElement) => {
// Find all fields inside the form, and
// make an array from them using the Array.from() method
const inputList = Array.from(formElement.querySelectorAll(".form__input"));
// Iterate over the resulting array
inputList.forEach((inputElement) => {
// add the input event handler to each field
inputElement.addEventListener("input", () => {
// Call the isValid() function inside the callback,
// and pass the form and the element to be checked to it
isValid(formElement, inputElement)
});
});
};