I have some radios in my page,and I want to do something when the checked radio changes,however the code does not work in IE:
$(\'input:radio\').change(...);
$( 'input[name="testGroup"]:radio' ).on('change', function(e) {
console.log(e.type);
return false;
});
This syntax is a little more flexible to handle events. Not only can you observe "changes", but also other types of events can be controlled here too by using one single event handler. You can do this by passing the list of events as arguments to the first parameter. See jQuery On
Secondly, .change() is a shortcut for .on( "change", handler ). See here. I prefer using .on() rather than .change because I have more control over the events.
Lastly, I'm simply showing an alternative syntax to attach the event to the element.