「ボタンにイベントを設定したはずなのに発火しない」 「チェックボックスにチェックが入ってもイベントが起きない」 こういう風になぜかイベントが発火しないことはjQueryを使っているとちょくちょく遭遇します。 しかもエラーも出ないし、DOMの読み込み後にイベントを設定してるのに関わらずです。 という訳でイベントが発火しないときの簡単にできる対処法について紹介 イベントが発火しないのはなぜ? まずなんでイベントが発生しないのか? ということですが、それは単純にイベントハンドラが登録されていないからです。 そもそもイベントハンドラが登録されてなければイベントは発火しようがありません。 ではどういうときにイベントが未登録になってしまうのか・・・ それは動的にボタンやチェックボックスなどの部品を追加したときです。 これだけだと分かりにくいので少し例を使って説明します。 例えば次のようなHTMLを作成