3

私たちの組織では、まだIE8標準を使用しています。EnterWebベースのアプリケーションの1つで、キーを介してフォームを送信できないことに気付きました。ウェブを検索した後、私はこの答えに出くわしました:https ://stackoverflow.com/a/4629047/731052

jQueryソリューションは機能しますが、ユーザーがキーを押すたびに「音」が鳴りEnterます。これを防ぐ方法はありますか?グーグルのようなサイトにいるとき、Enterキーを押しても「音」が聞こえません。ありがとう!

4

1 に答える 1

11

これを使って

if (e.which == '13') {
    e.preventDefault();
   //then put your code
   }

あなたがへのリンクを持っている質問からのコードを使用していたと仮定します

jQuery.fn.handle_enter_keypress = function() {
  if ($.browser.msie){
    $(this).find('input').keypress(function(e){
      // If the key pressed was enter
      if (e.which == '13') {
        $(this).closest('form')
        .find('button[type=submit],input[type=submit]')
        .filter(':first').click();
      }
    });
  }
}
于 2012-09-26T20:40:33.947 に答える