Take the 2-minute tour ×

I have a text type input field and a checkbox. If I change the text and then click outside the input box (or press enter or tab) the change event is thrown. But if I enter some text and then click directly on the checkbox using the mouse, only the checkbox change event seems to be thrown.

I have the following code:

<input type="text" name="text" class="update">
<input type="checkbox" name="check" class="update">

and this jQuery:


Is this a known problem, and how can I make sure all change events are fired/thrown/caught in this setup?

share|improve this question
Is that code in a $(document).ready(function()); function? You could try putting an alert() in the function to see if you're hitting the function. –  codersarepeople Jan 13 '11 at 21:55
Strange. Something else must be going on because my test works clicking from a changed text input to the checkbox jsfiddle.net/tbeseda/UCtyb –  tb. Jan 13 '11 at 21:58
Are you sure? I copied the HTML/JS and could see both the events firing when I type something in textbox and then click on checkbox. –  Chandu Jan 13 '11 at 21:59
You are calling same event at the same time, so one of this calls will respond, just change the event on the text box and call it with jQuery separately –  Mohammad Jan 13 '11 at 22:01
OK, so something else must be going on, you're right.. I'll make more tests. Actually I use the events to fire an ajax call, and only one of these ajax calls seems to be executed.. so I 'thought' it was the event not firing, but the problem may lie elsewhere.. –  mikkelbreum Jan 16 '11 at 21:05
add comment

3 Answers

up vote 1 down vote accepted

I'm not sure if I get it. But for me when I try to type in textfield and then click checkbox by mouse both events are fired. But you have to keep in mind that event 'change' for text input means that this input has to loose focus, as long as field is focused no change event ever will be triggered. This somehow might be your case. Checkboxes/radioboxes work different way tho. No need to loose focus.


P.S. My test case: http://dl.dropbox.com/u/196245/index16.html

share|improve this answer
add comment

The change event fires for both because you're listening to the update class.

share|improve this answer
add comment

The change event will not fire unless the input focus switched to other controls

share|improve this answer
add comment

Your Answer


