setting val() of radio or checkbox to single value sets "value" instead of "checked"

setting val() of radio or checkbox to single value sets "value" instead of "checked"


I created this as a ticket (http://dev.jquery.com/ticket/3609) and
attached a patch, but since I've presumed the intended behavior I
thought I should pose this to the mailing list.
The documentation of val() says, in the second section for val(val):
"Checks, or selects, all the radio buttons, checkboxes, and select
options that match the set of values."
And the example code shows that it works given a single non-Array
value to select the option on a non-multiple select:
$("#single").val("Single2");
But this does not work for radio or checkbox inputs. Given this HTML:
<input type="radio" name="ordinal" value="1">First</input>
<input type="radio" name="ordinal" value="2">Second</input>
code like this:
$("[@name='ordinal']").val("2");
surprisingly ends up setting the "value" attribute of all the radio
buttons to "2" like this:
<input type="radio" name="ordinal" value="2">First</input>
<input type="radio" name="ordinal" value="2">Second</input>
instead of setting the "checked" attribute on the radio button with
value "2" as expected, like this:
<input type="radio" name="ordinal" value="1">First</input>
<input type="radio" name="ordinal" value="2" checked>Second</input>