What the difference between .click and .change on a checkbox

qwertymk picture qwertymk · Apr 7, 2011 · Viewed 41.8k times · Source

I was looking around to add an event to a checkbox and I would have thought people would use .change to set up a change event but instead I found that people are using .click

Is there a reason for this? They both seem to work fine both with clicked events and with keyboard changes. Am I missing something?

If you don't believe me then try it out yourself

Answer

Mark Kahn picture Mark Kahn · Apr 7, 2011

onchange in IE only fires when the checkbox loses focus. So if you tab to it, hit space a few times, tab out, you'll only get one onchange event, but several onclick events.

Note: this is one of the very, very, very rare times when IE's behavior is correct (according to spec) and other browsers are wrong.