In Drupal 7, I had two sets of radio buttons on a form, which I needed to get the checked values of using Jquery. This seemed simple to accomplish using .val(), with this line from the Jquery documentation:
$('input:radio[name=bar]:checked').val(); // get the value from a set of radio buttons
Drupal’s Form API names radio button sets as “setName[radios]“, and Jquery needs “[" and "]” characters to be escaped with a double backslash, as mentioned on this post at the drupal forums. So I tried
var fooValue = $('input:radio[@name='foo\\[radios\\]']:checked").val();
var barValue = $('input:radio[@name='bar\\[radios\\]']:checked").val();
But these lines retrieved the checked value for the first set of radio buttons only. At this point, I tried a non-existing name, and still Jquery retrieved the same value.
After trying a few more tweaks that did not work, I found that getting the text of the labels for all radios would retrieve the checked value of each, in a string, delimited by a space. At last I found that this worked:
var allChecked = $(input:radio:checked + label").text.split(" ");
var fooValue = allChecked[0];
var barValue = allChecked[1];
which is weird and cumbersome but at least it works. Maybe the problem is because Drupal 7 depends on Jquery 1.5.2 and the current version is 1.6.2? No idea.