I always use the 'click' event and determine what state the checkbox is internally.
In this case I would trigger the click event once I have made the change. Extra line of code but good work around, like so
Main Topics
Browse All TopicsHere come's another IE complaint! This issue has been blogged all over the place with many possible solutions, however none seem to quite cut it and certainly not for my needs.
The issue is how IE handles change events, which is does completely different from all other major browsers. My particular case is with checkbox's. A change event should be thrown when the checkbox is checked or unchecked. The problem is that the change event isn't thrown until the checkbox or the rest of the screen grabs focus. The inconsistency between IE and other browsers for me renders using the change event useless. People work around using the onclick event handler, however this does not work if the state of a checkbox is being changed programatically, which should still result in a change event being thrown since a change has occurred(!)
Despite this issue being blogged in many places i haven't seen it posted here and often tend to get good responses here. Can anyone give a workaround so that IE reacts to changes (throwing a change event) immediately once it's state changes, which includes it being changes programatically i.e:
$('#mycheckbox').attr('che
I'm using jQuery but any straight solution in javascript will be fine.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sadly i think you're right, and thanks for atleast confirming my suspicions even if i don't like it! :) Atleast then i don't waste my time, i have worked around not using the change event, but my code would be so much cleaner if it could be used as was intended!
Am going to leave the question posted a while longer before awarding credit, many thanks.
>>People work around using the onclick event handler, however this does not work if the state of a checkbox is being changed programatically,
If I understand correctly, you have something similar to:
<input type="checkbox" id="chk" onclick="someHandlerFuncti
and the state of the checkbox is being changed by doing something similar to:
$("chk").attr("checked","c
or perhaps:
document.getElementById("c
and then you are expecting that action to call someHandlerFunction(). IF that is the case do NOT change the attribute. Instead do literal "click" on the checkbox. On other words, do:
$("#chk").click();
Hi guys,
I think you've missed an important case, whereby programatically i may want to set the "checked" value of a checkbox to a specific state without necessarily knowing whether it is already in that state, and i only want the code to run if it's state was changed. I do like the suggestion to never change the state via setting the attribute, but rather to always change it via click().
So i think the solution is really to always check the state before calling the click, i.e:
When changing a checkbox to "checked=true" do:
if (chkbox.attr('checked')!=t
.. and similarly when changing to "checked=false" do:
if (chkbox.attr('checked')!=f
I think this ensures that the code is cross-browser.. and allows me to treat the checkbox click() event as an onchange() event. I am happy to award credit since the above comments inspired my solution, which is now MUCH better than what i had been doing(!)
Beforehand however, can anyone see a flaw in my solution?
>>if (chkbox.attr('checked')!=t
>>if (chkbox.attr('checked')!=f
that's exactly how I would expect you to set the checkbox to a specific state (as opposed to $('#mycheckbox').attr('che
$('#mycheckbox').attr('che
does not work in IE, but it works in others, then using something lke:
$('#mycheckbox').attr('che
should theoretically call the onchange event handler immediately followed by the click handler in NON-IE browsers. When both, the onchange event handler and the onclick event handler are the same function reference, then this may NOT be what you want. I didn't realize earlier that this was previously suggested:
$('#mycheckbox').attr('che
but I suspect it will create cross-browser problems. Stick with:
>> if (chkbox.attr('checked')!=t
Business Accounts
Answer for Membership
by: manjunathubPosted on 2009-11-05 at 03:13:35ID: 25748315
it is a serious bug in IE you can complain to Microsoft people.. so they can rectify it in there future release.. and it is a good observation...