// 用Jquery实现:

$('#input-element').on('input',()=>{
  console.log("你按了一下111");
})

// 用Jquery的事件委托实现:

$("body").delegate( $("#input-element"), "propertychange input", function () {

//  do something
console.log("你按了一下222");
});
 // propertychange input 是关键
 
 
// 用原生js实现:
let inputElem = document.getElementById("input-element");
inputElem.oninput = function(){
  console.log("你按了一下");
}
 
// 用原生js的事件委托实现:

document.oninput = function(e){

  if (e.target.id === "input-element") {  // 也可以用其他判断方法

    console.log("你按了一下");

  }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2022-01-14
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案