제이쿼리 input radio가 체크되면 다음버튼 활성화 되게 질문입니다
본문
<div class="survey_element2">
<div class="reservation_wrap2">
<div class="reservation_time">
<p><img src="<?php echo G5_IMG_URL;?>/time_icon.svg">시간 선택</p>
<img src="<?php echo G5_IMG_URL;?>/arrow_down.svg">
</div>
<div class="black_line"></div>
</div>
<div class="reservation_wrap2_down">
<label for="time">
<input type="radio" name="time" id="time" hidden value="">
<p class="time_text">9:00 ~</p>
</label>
<label for="time">
<input type="radio" name="time" id="time" hidden value="">
<p class="time_text">9:30 ~</p>
</label>
<label for="time">
<input type="radio" name="time" id="time" hidden value="">
<p class="time_text">10:00 ~</p>
</label>
<label for="time">
<input type="radio" name="time" id="time" hidden value="time"/>
<p class="time_text">11:00 ~</p>
</label>
<div class="time_select">
<p class="select_ok"><span></span>선택</p>
<p class="select_no"><span></span>불가</p>
</div>
<div class="grey_line"></div>
</div>
</div>
---> 스크립트
function next_btn_validation(index){
if(index == "1") {
var count = 0;
$('select[name=questions] :selected').each(function(){
if($(this).val() > 0){
count++;
}
if($(this).val() > 0){
$('#next_btn').prop('disabled', false);
}else {
$('#next_btn').prop('disabled', true);
}
//비활성화일때 다음으로 넘어가기 방지
});
console.log(count);
}else if(index == "2"){
//var count = 0;
var count2 = $('input:radio[name=time]:checked').val();
$('input:radio[name=time]').on('change', function(){
if($(this).val == ''){
}
})
console.log(count);
}else if(index == "3"){
}
var total_question_count = $('.q' + index).find('.my_hidden_input').val();
if(count == total_question_count){
$('#next_btn').attr('class','next');
}else {
$('#next_btn').attr('class','btn_deactivated');
}
}
// select 할때 next_btn_validation
$('select[name=questions]').on('change', function(){
var index = $('#navigation').find('li.active').index();
next_btn_validation(index);
});
//input check 할때 next_btn_validation
$('input:radio[name=time]').on('change', function(){
var index = $('#navigation').find('li.active').index();
next_btn_validation(index);
})
input이 체크가 되면 넘어가게 하고 싶습니다... 짜다가 도저히 머리가 안돌아가 고수님들께 여쭤봅니다...
답변 1
$('input:radio[name=time]').on('change', ....);
radio 버튼에서 change 이벤트가 있는지 모르겠네요.
click 등으로 해 보세요.