1
1

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.

テキストボックスの変更感知(jQuery)

Last updated at Posted at 2015-10-28

どうでも良いんだけど、テキストボックスの変更感知をしてインクリメンタルサーチとかをするときにイベントがいまいち拾えなかったのでメモ。

  $(document).on 'input change keyup', '#id', ->
    # テキストに文字が入っているかどうか?
    if $(@).val().length > 0
      # テキストが入っている場合の処理
    else
      # テキストが入ってない場合の処理

複数のイベントを捕まえれば入力中の文字列も拾える。

JSのみで検索する場合。

jquery-searcherを使うとJSだけの検索がやりやすかった。
上記のメモはこのコードの中を読んで知った。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?