0

I have a group of radio buttons and upon clicking a link I want to execute one of the radio buttons in the group...in this case the one with an Id="IndividualPD".

This is the html for the radio buttons

<div class="btn-group" id="performanceRadioBtns" data-toggle="buttons" style="margin-     top: 20px; float: right">
   <label class="btn btn-primary active">
        <input type="radio" name="options" id="PDStatus">
        PD Status
   </label>

   <label class="btn btn-primary">
        <input type="radio" name="options" id="PDRating">
        PD Rating
   </label>
   <label class="btn btn-primary">
     <input type="radio" name="options" id="IndividualPD">
     Individual PD
   </label>
</div>

This is the jquery for what I have tried.

$("#performanceRadioBtns").find("#IndividualPD").find("input[name='options']").trigger("change");

but doesnt activate the button.

Help perhaps on how to 'trigger' this button upon clicking a link

2
  • If your IDs are unique as they should be, you'll only just $('#IndividualPD') to get to the radio button.
    – techfoobar
    Feb 15, 2014 at 14:21
  • What does it mean when you say "execute" one of the radiobuttons? The change-event will be triggered on clicking the radiobutton even without the script.
    – Esko
    Feb 15, 2014 at 14:29

1 Answer 1

1

If you want to check the radio button, you need to use prop("checked", true)

As well as changing your selector to:

$("#performanceRadioBtns").find("#IndividualPD").prop("checked", true);

since #IndividualPD is already the input element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.