Leon Helmsley
Leon Helmsley

Reputation: 595

Change event handler and mutually exclusive radios

According to here, the change event handler fires when the value changes. What about with mutually exclusive radio buttons? Selecting one button would set one button to "unchecked" and another to "checked". Would the change event handler fire for both of these elements?

EDIT: Nevermind, I found the answer.

Upvotes: 0

Views: 80

Answers (3)

hulufei
hulufei

Reputation: 767

The change event will only fire on the radio you "checked", and if you use attr('checked', 'checked') to set/unset the radio, it will not fire the change event.

Upvotes: 0

Cole Pilegard
Cole Pilegard

Reputation: 582

It will fire for both, if you have event handlers on both radio buttons. But since they're mutually exclusive, you probably only need the listener on one of them, and get their states from that.

Upvotes: 0

Centijo
Centijo

Reputation: 604

Assuming these are two radio buttons with the same "name", you will only get one onChange event because only one field value is changing.

Upvotes: 1

Related Questions