2014-02-15 3 views
0

라디오 버튼 그룹이 있으며 링크를 클릭하면 그룹의 라디오 버튼 중 하나를 실행합니다 ...이 경우에는 Id = "IndividualPD" . 링크를 클릭하면 라디오 버튼을 클릭하십시오.

는 라디오 버튼

<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> 

이 내가 시도 무엇에 대한 JQuery와 인에 대한 HTML이다.

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

버튼을 활성화하지 않았습니다. 아마도 '트리거'는 라디오 버튼을 체크하려면 링크

+0

이다, you'l l 라디오 버튼에 접근하기 위해서'$ ('# IndividualPD')'만하십시오. – techfoobar

+0

라디오 버튼 중 하나를 "실행"한다고 말하면 무엇을 의미합니까? change-event는 스크립트없이 라디오 버튼을 클릭하면 트리거됩니다. – Esko

답변

1

을 클릭시이 버튼에, 당신은 prop("checked", true)

를 사용뿐만 아니라 당신의 선택을 변경해야하는 방법에 대한

도움말 :

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

귀하의 ID를 그들이이어야하는 고유의 경우 이미 input 요소

관련 문제