Without giving loads of unnecessary details (details upon request) I'm changing which radio button is selected through the following code, let's say when a button called "reset radio" is clicked the following code gets executed:
$("input:radio[name=resetName][value=resetValue]").attr("checked", true);
Let's also say:
var resetName = radiobuttons;
var resetValue = radioButton1;
var resetID = radioButton1;
I execute some more code when one of the radio buttons is selected, and I'm listening to the event through .change() handler.
However, the following scenario jams things up.
1. click on radioButton3
2. reset the selected value to radioButton1 through the handy "reset" button
3. click on radioButton3 again
What happens here is that the radio button resets on the screen, but since I'm using an .change event handler, somehow jquery still thinks that radioButton3 is selected, so it doesn't see a change. I can only get radioButton3 selected by clicking on a different radio button first, then clicking on radioButton3. How do I fix this so that jquery sees the value changing as well as on screen?
Fiddle: http://jsfiddle.net/h255E/5/
checkedto be a property not an attribute so best practice suggests using.prop('checked', true);