Показать сообщение отдельно
  #16 (permalink)  
Старый 30.10.2013, 16:55
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,103

Сообщение от Купэ
определить в каком контейнере <div> он находится и перебрать следующие за ним селекты
Вариант...
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

</head>

<body>
 <div class="cont">
   <select id="select_1">
     <option>1</option>
     <option>test</option>
   </select>

   <select id="select_2">
     <option>1</option>
     <option>test</option>
   </select>

   <select id="select_3">
     <option>1</option>
     <option>test</option>
   </select>

   <select id="select_4">
     <option>1</option>
     <option>test</option>
   </select>

</div>

<div class="cont">
   <select id="select_5">
     <option>2</option>
     <option>test</option>
   </select>

   <select id="select_6">
     <option>3</option>
     <option>test</option>
   </select>

   <select id="select_7">
     <option>4</option>
     <option>test</option>
   </select>

    <select id="select_8">
     <option>5</option>
     <option>test</option>
   </select>
</div>

<script>
   $("body").on("change","select",function(){
   var main_container = $(this).parents('.cont');
   var count_select = $("select[id^='select_']", main_container);
   var i = count_select.index(this);
   // вариант без перебора
   count_select.slice(++i).prop("disabled", true)
   // вариант с перебором
   //count_select.each(function(indx, element){
   //if(indx > i) $(element).prop("disabled", true)
   // })
  })
</script>
</body>

</html>
Ответить с цитированием