I have this code, which works fine:
if ( $('table#attribute_Size input.quantitycheckbox:checked').length == 0 )
$('table#attribute_Size input.quantitycheckbox:first').attr({ checked: true });
As you can see though, it's pretty long and most of the selector is repeated. Is there a neat was to shorten it? I tried this but it doesn't work (I assume it's looking at nested elements instead of the current selector).
var $sizeRadios = $('table#attribute_Size input.quantitycheckbox');
if ( $(':checked', $sizeRadios).length == 0 )
$(':first', $sizeRadios).attr({ checked: true });