Kod
var ile = '1'; //ile wierszy pokazać
$('#zwijana_0 tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_0').toggle(function(){
$('#zwijana_0 tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_0 tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
$('#zwijana_1 tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_1').toggle(function(){
$('#zwijana_1 tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_1 tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
$('#zwijana_2 tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_2').toggle(function(){
$('#zwijana_2 tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_2 tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
$('#zwijana_0 tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_0').toggle(function(){
$('#zwijana_0 tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_0 tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
$('#zwijana_1 tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_1').toggle(function(){
$('#zwijana_1 tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_1 tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
$('#zwijana_2 tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_2').toggle(function(){
$('#zwijana_2 tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_2 tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
Kod
for(var count=0; count<=$("div#sites table").length-1; count++) {
$('#zwijana_'+count+' tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_'+count+'').toggle(function(){
$('#zwijana_'+count+' tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_'+count+' tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
};
$('#zwijana_'+count+' tbody tr:nth-child('+ile+')').nextAll().hide();
$('.przycisk_'+count+'').toggle(function(){
$('#zwijana_'+count+' tbody tr:nth-child('+ile+')').nextAll().show();
return false;
},
function(){
$('#zwijana_'+count+' tbody tr:nth-child('+ile+')').nextAll().hide();
return false;
});
};
sprawdzałem w konsoli i iteruje poprawnie
Kod
console.log(count);
Pomóżcie proszę, bo już nie mam pomysłu, gdzie może być przyczyna tego problemu.