js_对输入框按下enter键会触发change事件
- 测试代码
<body>
<input type="text" id="i1" />
<script>
const oI1 = document.querySelector('#i1')
oI1.addEventListener('keydown', function (e) {
console.log(e.key)
})
oI1.addEventListener('change', function () {
console.log('change')
})
</script>
</body>