html jQuery |用户按“Enter”键时检测

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html jQuery |用户按“Enter”键时检测相关的知识,希望对你有一定的参考价值。

// Show hidden search when pressing 'enter' key
$('#toggleSearch').keypress(function (e) {
  var key = e.which;
  if(key == 13)  // the enter key code
  {
    $('#searchDropdown').slideToggle();
    return false;
  }
});
<i tabindex="0" class="fas fa-search fa-2x" id="toggleSearch"></i>

以上是关于html jQuery |用户按“Enter”键时检测的主要内容,如果未能解决你的问题,请参考以下文章