는 방법을 확인하는 라디오 버튼을 사용하여 확인 JQuery?

나는 두 개의 라디오 버튼이나 그룹을 확인하고 싶어 라디오 버튼을 체크하거나 사용하지 않 JQuery,어떻게 해야 하나요?

질문에 대한 의견 (3)
해결책

주어진 그룹의 라디오 버튼

<input type="radio" id="radio1" name="radioGroup" value="1">
<input type="radio" id="radio2" name="radioGroup" value="2">

는지 여부를 테스트할 수 있습 특정한 한 사용하여 확인 jQuery 다음과 같다:

if ($("#radio1").prop("checked")) {
   // do something
}

// OR
if ($("#radio1").is(":checked")) {
   // do something
}

// OR if you don't have ids set you can go by group name and value
// (basically you need a selector that lets you specify the particular input)
if ($("input[name='radioGroup'][value='1']").prop("checked"))

을 얻을 수 있습의 값은 현재 확인 한 그룹에서는 다음과 같다:

$("input[name='radioGroup']:checked").val()
해설 (1)

<전> <코드> //다음과 같은 코드를 확인합하는 경우 라디오 버튼을 이름을 다음과 같'yourRadioName' //은 체크인 또는지 $(document).ready(function(){ if($("입력:라디오[name='yourRadioName']").가(":checked")){ //적 검사 } }); </드> </전>

해설 (1)

이는 최상의 방법

$("input[name='radioGroup']:checked").val()
해설 (0)

3.3.1jQuery

if (typeof $("input[name='yourRadioName']:checked").val() === "undefined") {
    alert('is not selected');
}else{
    alert('is selected');
}
해설 (0)

체크인이 하나도:

$(document).ready(function() { 
  if($("input:radio[name='yourRadioGroupName'][value='yourvalue']").is(":checked")) { 
      //its checked 
  } 
});
해설 (0)

어떤 답을 한 단계 더 나아가-당신이 할 경우 다음과 같은 확인할 수 있습니다면 어떤 요소에 라디오 그룹을 확인:

if($(&#39;입력[name="yourRadioNames"]:체크&#39;).val()){(확인)또는if(!$(&#39;입력[name="yourRadioNames"]:체크&#39;).val()){(선택되지 않음)

해설 (0)

라디오 버튼은,

<input type="radio" id="radio_1" class="radioButtons" name="radioButton" value="1">
<input type="radio" id="radio_2" class="radioButtons" name="radioButton" value="2">

을 확인에 클릭

$('.radioButtons').click(function(){
    if($("#radio_1")[0].checked){
       //logic here
    }
});
해설 (0)