jQuery Set + Unset Radio Buttons

Sam Deering

Simple jQuery code snippets to set and unset input values on radio buttons. Just thought I would share because I was having a few issues with earlier versions of jQuery and setting radio buttons on a form.

//jQuery Set Radio Button
$('input[name="correctAnswer"]').attr('checked', false);

//To unselect the button

//jQuery (1.4+) code to pre-select one button :
var presetValue = "black";