Is it possible to select a hidden radio button

Is it possible to select a hidden radio button

Ran into an issue today I wasn't able to sort out on my own or through a Google search:

I have this form where I wanted to select a radio button when the containing div was clicked. So, on the click of the div, I would say that the radio's attribute of checked was set to checked.

It all worked fine until I put on the document.ready to hide all the radios.

Thus, with a hidden radio input, I was unable to manipulate the checked attribute. Did I miss something? Example code for reference:


  1. $(document).ready(function(){
  2.     $("input[type=radio]").hide();
  3.     $("form div").click(function(){
  4.         $(this).find("input[type=radio]").attr("checked","checked");
  5.         $("form").submit();
  6.     });
  7. });


So to re-iterate, if I didn't have that initial hide in there, it'd work. Also, if I did

  1. ...
  2.         $(this).find("input[type=radio]").show().attr("checked","checked");
  3. ... 

It also worked. So, I wanted to clear up what I may have missed as to why it didn't work. Thanks!