$("someElement").on("keydown", function(event){

  var key = event.which;

  if(key == 13){

    e.preventDefault();

    doSomething();

  }

});

IE使用event对象的keyCode属性储存被按下的键。而其它浏览器使用event的which属性。

jquery封装后,统一使用which属性

相关文章:

  • 2021-07-15
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案