m0_38034574
m0_38034574
2019-01-26 22:09

有没有大神可以帮我看一下,原生JS文本框绑定回车和esc键没有反应啊啊?

5
  • chrome
  • html5
  • javascript
  • ecmascript



Submit var btn = document.getElementById("submit-btn"); var val = document.getElementById("name"); btn.onclick = function () { v = val.value; console.log(v); }; val.onkeydown = function (event) { if (event.code== 13) { console.log(v); } if (event.code == 27) { v = " "; } }

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答