8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

autocomplete で入力中に候補を選択した場合、フォームにセットされない

Posted at

autocomplete 便利ですね。
でも日本語だと、入力中でもサジェストが表示されて「あら便利」と候補を選択してもフォームにセットされません。
場合によっては選択した候補と入力中の文字が混ざったりと変なことになります。

そういった場合の対応方法。

select メソッドでフォーカスを外してあげるといい感じに動きます。

javascript
  select: function( event, ui ) {
    // フォーカスを外す
    $(this).blur();
  }

8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?