❮ HTML Event Attributes Example Execute a JavaScript when a user writes something in an <input> field: <inputtype="text"oninput="myFunction()"> Try it Yourself » Definition and Usage The oninput attribute fires when an element gets user input. ...
输入事件是一个UI-Event,它意味着在用户对页面执行操作时触发,而不是在脚本执行操作时触发。对于您的情况,脚本只需在设置.value时调用相同的回调即可。 let button = document.querySelector("button");let firstNameInput = document.querySelector("#firstName");const setBorderColor = () => { firstNameIn...