Radio Button Onclick vs. Onchange Event

Radio buttons respond to both onchange and onclick events in JavaScript. However, the onchange event may not work as one would expect. The onchange event is not triggered when turning a radio button on and off but only one or the other.

Most browsers trigger onchange when the radio button is selected, but Internet Explorer prior to version 9 triggers onchange when the radio button is deselected.

Onclick / Onchange Example

The example below reports onchange and onclick events for the radio buttons so you can observe the results in various browsers.

Demo: Onchange vs. Onclick

Select your favorite mode of transportation:

Click on radio buttons above to see information about the events displayed here.

Examples provided in this tutorial favor the onclick event.