So I do have this loop, but it stops when it come to function after effect , also when I remove that code from loop and define x by me, it does work correctly. What is stopping that function after effect? Also when I’ve tryed without fadeTo and removed that function that is after effect and just putted it behind comma ($('#item' + x + ' p').html(obchody[window.obchod][x]['doby_a_kontakty']) it worked too (but with some error and stopped after first loop).
for (var x in obchody[window.obchod]) {
$('#item' + x + ' p').fadeTo(350, 0, function () {
$('#item' + x + ' p').html(obchody[window.obchod][x]['doby_a_kontakty']).fadeTo(350, 1);
});
}
The problem continues, now when I use this instead of $('#item' + x + ' p'), it runs but late. Here is an example, I added to code something like counter – nuber(number inside function).
y = '';
for (var x in obchody[window.obchod]) {
y += ' ' + x + '(';
$('#item' + x + ' p').fadeTo(350, 0, function () {
y += x + ')';
$(this).html(obchody[window.obchod][x]['doby_a_kontakty'] + y).fadeTo(350, 1);
});
}
And the result of this test is: y==0( 1( 2( 3( 4( 5( 6( 7(7)7)7)7)7)7)7)7) and I need it run like y==0(0) 1(1) 2(2) 3(3) 4(4) 5(5) 6(6) 7(7), because I can’t use x in that but this wouldn’t help there.
Try this…