Q:

jquery radio group toggle on click

$("input[name=sample]").click(function(){
            $("#"+$(this).val()).show();
            $("#"+$("input[name=sample]:not(:checked)").val()).hide();
    });
}); 

I was using this for switching between two divs.  But when i added a third div and radio button, this didn't work for third one.  It shows on click but doesn't hide others.  What can cause this? 

A:

You now have more than one element to hide, so use something like :
$('input[name="sample"]').on('click', function(){
      $("#"+this.value).show();
      $("input[name=sample]:not(:checked)").each(function() {
          $('#'+this.value).hide();
      });
}); 

