2017-01-25 5 views
1

У меня есть теги опций. И в каждом содержимом каждой вкладки есть 4 переключателя. Их нужно проверить. но Он проверяется только при выборе первой опции страницы содержимого.Проверьте все переключатели, разделив содержимое вкладки

<div class="user_select mb30"> 
<select class="form-control input-sm multiple h40" name="user_select"> 
    <option value="select1">講演者1</option> 
    <option value="select2">講演者2</option> 
    <option value="select3">講演者3</option> 
    <option value="select4">講演者4</option> 
    <option value="select5">講演者5</option> 
    <option value="select6">講演者6</option> 
    <option value="select7">講演者7</option> 
    <option value="select8">講演者8</option> 
    <option value="select9">講演者9</option> 
    <option value="select10">講演者10</option> 
</select> 

<input type="radio" value="radio1" name="file01"><label>配布する</label> 
<input type="radio" value="radio2" name="file02"><label>配布しない</label> 

<input type="radio" value="radio03" name="file03"><label for="radio03">公開する</label> 
<input type="radio" value="radio04" name="file04"><label for="radio04">公開しない</label> 

$(document).ready(function() { 
var counter = 0 -1; 
$('[name=user_select]').children('option').each(function(){ 
    counter++; 
}); 
for (var i = 1 ; i <= counter ; i++) { 
    $('.tab-pane:first').clone().attr('id','select' + (i+1)).appendTo('.tabContent'); 
} 
$('.tab-pane').hide(); 
$('.tab-pane:first-child').show(); 

$('[name=user_select]').change(function() { 
    var userNama = $('[name=user_select]').val(); 
    var idName = '#'+userNama 
    $('.tab-pane').hide(); 
    $(idName).fadeIn(400); 
}); 

Я не знаю, следующий источник я попробовал.

$(document).ready(function() { 
var select_num = $('option[value!=""]').val().length; 
var z = select_num * $('input[type=radio]').length; 
for (var x = 1 ; x <= z ; x++) { 
      $('.tab-pane input[type=radio]').each(function(x){ 
       // $(this).attr('type','radio'); 
       // $(this).attr('id','radio' + (x+1)); 
       $(this).attr($('label[for='+ $(this).attr('id','radio' + (x+1)) +']')); 
      }); 
      // $('.tab-pane label').each(function(y){ 
      // $(this).attr('for','radio' + (y+1)); 
      // }); 
    } 
    }); 
+0

Можете ли вы предоставить код из вкладок вы говорите о? – profuel

+0

"* Их нужно проверить *" - когда? Зачем? На основании какого события или взаимодействия? –

ответ

0

Вы можете прикрепить данные-Parametr к вашему радио:

$(document).ready(function() { 
 
    $('[name=user_select]').change(function() { 
 
    var userNama = $(this).val(); 
 
    var idName = '#' + userNama; 
 
    $('.tab-pane').hide(); 
 
    $('input[type="radio"]').prop('checked', false); 
 

 
    $(idName).fadeIn(400); 
 
    $('input[data-tab="' + userNama + '"]').prop('checked', true); 
 
    }); 
 
});
.tab-pane { 
 
    display:none; 
 
} 
 
#select1 { 
 
    display: block; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
<select class="form-control input-sm multiple h40" name="user_select"> 
 
    <option value="select1">講演者1</option> 
 
    <option value="select2">講演者2</option> 
 
    <option value="select3">講演者3</option> 
 
</select> 
 
<div class="tab-pane" id="select1"> 
 
    <h2>Tab 1</h2> 
 
</div> 
 
<div class="tab-pane" id="select2"> 
 
    <h2>Tab 2</h2> 
 
</div> 
 
<div class="tab-pane" id="select3"> 
 
    <h2>Tab 3</h2> 
 
</div> 
 

 
<h2>Radios</h2> 
 
<div> 
 
    <input type="radio" data-tab="select1" value="radio1" name="file01" checked> 
 
    <label for="radio01">file01</label> 
 
    <input type="radio" data-tab="select1" value="radio2" name="file02" checked> 
 
    <label for="radio02">file02</label> 
 
    <input type="radio" data-tab="select1" value="radio3" name="file03" checked> 
 
    <label for="radio03">file03</label> 
 
    <input type="radio" data-tab="select1" value="radio4" name="file04" checked> 
 
    <label for="radio04">file04</label> 
 

 
</div> 
 
<div> 
 
    <input type="radio" data-tab="select2" value="radio1" name="file05"> 
 
    <label for="radio05">file05</label> 
 
    <input type="radio" data-tab="select2" value="radio2" name="file06"> 
 
    <label for="radio06">file06</label> 
 
    <input type="radio" data-tab="select2" value="radio3" name="file07"> 
 
    <label for="radio07">file07</label> 
 
    <input type="radio" data-tab="select2" value="radio4" name="file08"> 
 
    <label for="radio08">file08</label> 
 
</div> 
 
<div> 
 
    <input type="radio" data-tab="select3" value="radio1" name="file09"> 
 
    <label for="radio09">file09</label> 
 
    <input type="radio" data-tab="select3" value="radio2" name="file10"> 
 
    <label for="radio10">file10</label> 
 
    <input type="radio" data-tab="select3" value="radio3" name="file11"> 
 
    <label for="radio11">file11</label> 
 
    <input type="radio" data-tab="select3" value="radio4" name="file12"> 
 
    <label for="radio12">file12</label> 
 
</div>

 Смежные вопросы

  • Нет связанных вопросов^_^