0

i have a problem with this code

for (var i=1,x=2; i<12,x<12; i++,x++){
  $('#btnMas'+[i]+'').click(function(evento) {
    $('#btnMas'+[i]+'').fadeOut(0);
    $('#tabla'+[x]+'').fadeIn(0);
    $('#btnMas'+[x]+'').fadeIn(0);
  });
}   

the problem is that the function dosn't work properly and when i change the code to:

$('"#btnMas'+[i]+'"').fadeOut(0);

and check with firebug it says that the value for btnMas is btnMas12 whe it should be 1 not 12

EDIT: i chaged btnMas11 to 12, i relize that the loop completes before passing the value to the lower ones it pas the full loop value i.e. i<6 it becomes btnMas6 or i<40 becomes btnMas40, but i dont know how to fix it, beside i have read already the suggested topic but i cant get an answer from it.

i need some guidence, i have read that i shouldnt be creating a function inside a for loop, but im new in the use of js files so i don't know how to create a function that could do what i need in here. plus this is a js file and not my html wich is in a diferen folder i'm not english native, so please forgive me if theres any grammar mistake, because of this i dont know if i express to it fulliest my problem :(

0 Answers0