Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top