2014-10-11 2 views
0

의 값에 대한이 메소드를 사용. 이러한 선택을 더 많이하고 여러 번 사용하기 때문에 변수에 수동으로 값을 할당하는 대신 this을 사용하려고 생각했습니다. 그러나 아래 코드는 작동하지 않습니다.나는 JQuery와 모바일이 필드 셋은 라디오 버튼

누군가가 도와 줄 수 있습니까? 당신은 라디오 <input>이 각 그룹에 체크되어 있는지 확인하려는, 귀하의 질문에 대한 코멘트에, 정화 감안할 때

if($("#uni").is(":checked") || $("#coll").is(":checked")) { 
edu = $(this).val(); 
    } else { 
     return false 
    } 
+0

[JSFiddle] (http://jsfiddle.net)을 만드시겠습니까? – Wouter0100

+0

왜 '최고 교육'에 대한 옵션이 '성'이라는 이름으로 주어 집니까? 그리고 모든 그룹에서 하나의 라디오가 선택되어 있는지 확인하고 싶습니다. –

+0

@DavidThomas 예, 그룹 단위로 확인하고 싶습니다. 성별 이름은 여전히 ​​다른 메뉴의 복사/붙여 넣기 형식입니다. –

답변

1

, 난 좋을 것 :

// selects all the relevant fieldsets (on the assumption they all 
// share the same 'data-role' attribute and value: 
var fieldsets = $('fieldset[data-role="controlgroup"]'), 
// compares the number of fieldsets with the number of fieldsets that have... 
    allChecked = fieldsets.length === fieldsets.filter(function(){ 
     // one, or more, checked radio inputs: 
     return $(this).find('input[type="radio"]:checked').length; 
    // and assesses whether the number of fieldsets is the same as the 
    // number of fieldsets with at least one radio input checked 
    }).length; 

참조를 :

관련 문제