views:

194

answers:

1
<input id="myCheckbox" type="checkbox" /> Please, please check me
    <input id="myRadio" type="radio" /> Am I selected ?

I would like the following behavior:

  1. When myCheckbox is checked then myRadio is going to get selected.
  2. When myCheckbox is unchecked then myRadio is going to become unselected.

How will I do this in a very simple way ?

Thank you in advance for your effort to respond.

+4  A: 
$('#myCheckbox').click(function() {
    if ($(this).is(':checked')) {
        $('#myRadio').attr('checked', 'checked');
    } else {
        $('#myRadio').removeAttr('checked');
    }
});
Ken Browning
Wow. That was fast. Thank you!
iHello