09 March 2011

CheckBox "onchange" event fired before "onclick" event in Google Chrome

Hi,

      When working on another Javascript Library I have found another problem or maybe I am wrong and this is expected behavior. The problem is:
           - In Internet Explorer - onchange event is fired after the onclick event;
           - In Google Chrome - onclick event is fired after the onchange event.

      I am not sure about other browsers.

      All this refers to checkbox only, because I didn't try others, but I guess radiobuttons have the same issue.



      I have found this really annoying because logically you first click the checkbox and just after that it changes (become ticked or un-ticked).

      So pay attention to this small issue.

      I have found some articles which states that when a checkbox is un-ticked and you click on it then on onclick event this.checked will still return false, but on onchange event this.checked will return true as the checkbox is ticked. BUT I tried this by myself and I could not reproduce this so I guess this is wrong, however better would be to try it by yourself.

No comments:

Post a Comment

your thoughts are welcome:

Need more? Leave comments and subscribe to my blog.

.