views:

643

answers:

1

Hi,

I have 3 radio buttons with attached callback:

$('#formBuilding input[type="radio"]').change(projectChangeHandler);

In callback projectChangeHandler I access radio value with:

var currentSelection = $('#formBuilding input:radio:checked').val()

In IE 7, unlike to other browsers, currentSelection has value from radiobutton which has been unselected. In other browsers, currentSelection has value from radiobutton which was clicked (or gained focus).

How to solve it to be crossbrowser?

Thanks Paweł

+3  A: 

For radio buttons, you should use the click event. Although it may sound strange, but the click event will also fire when selecting the radio button with the keyboard, so there are no issues with accessibility.

Philippe Leybaert
It works, thanks a lot! Anyway, is it (and other similar event issues) standardized by some kind of document or specification?
dragonfly
Haven't found any I must say. Note that checkboxes show the same behavior, so you should also use the click event on them.
Philippe Leybaert
http://www.quirksmode.org/dom/events/index.html will have a good amount of the info that you're looking for.
ajm