#checkbox #jquery

jQuery checkbox checked event

jQueryでチェックボックスの状態を監視するイベントはclick eventを使う。

チェックされたかを判断するには$("#some_checkbox").is(':checked')がいい。

CoffeeScriptでのサンプルコード:

change eventも監視はできるが、取れる値は遅延されるみたいです。

The change event is sent to an element when its value changes. This event is limited to input elements, textarea boxes and select elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.

参考:http://forum.jquery.com/topic/jquery-checkbox-checked-event

Qihuan Piao

Qihuan Piao

Originally from China and now living in Tokyo, I started this blog to practice English. Over the years, writing helped me find my own voice and explore thoughts about identity, life, and ordinary things that catch my curiosity. I mostly write for myself, but I love it when something here connects with someone else.

Meanwhile, what I wrote in Japanese

2012年の目標

January 1, 2012