Купэ,
на всякий случай Цитата:
|
Цитата:
var main_container =$(this).parent('.cont'); -выбираем родителя нажатого селекта т.е. это будет один из дивов с классом .cont
Надо у селектора $("#select_"+i), определить блок- родитель и у него добавить атрибут Подобная конструкция не работает
("#select_"+i).parent(main_container).prop("disabled",true);
|
Цитата:
http://javascript.ru/forum/jquery/42...tml#post278781 Достаточно написать $(this).parent(); // или $(this.parentNode); Цитата:
|
Сделал вот так правильно было написать:
$(main_container).children("#select_"+i).prop("disabled", true);
|
prop("disabled",true); - атрибут disabled активирует, кстати нормально работает, можно и так .attr("disabled","disabled");
|
Цитата:
<!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>
|
У меня так не пойдет потому что в каждом контейнере id селектов одинаковые select_1 select_2, потому что эти списки соответствуют уровням вложенности каталога т.е. select_уровень вложенности,
|
Цитата:
|
Цитата:
|
| Часовой пояс GMT +3, время: 12:54. |