I am trying to check radio. Neither the following works:
[edit]
$(\'selector\').attr(\'checked\',\'checked\');
$(\'selector\').attr(\'checked\',true)
It works, but
$('input[name="myname"][checked]').val()
will return the value of the first element with attribute checked. And the a radio button still has this attribute (and it comes before the b button). Selecting b does not remove the checked attribute from a.
You can use jQuery's :checked:
$('input[name="myname"]:checked').val()
DEMO
Further notes:
$('b').attr('checked',true); is enough.