I have a simple problem in passing variables from one function to a Jquery handle function. In the first function I have a for loop going over a list of items. the function inserts a picture and I want to append a onclick() Jquery handle to the image. The onclick() calls a function that passes the indx of the for loop. Instead of having the value passed the reference is passed so all the onclick handles end up with the same value (the last value of the for loop). the code is as follows:
function setAlbums()
{
for(var indx=0;indx<$("li.mainSpPic").length;indx++)
{
....
$("li.mainSpPic").eq(indx).children("img").eq(0).click(**function(){chngAlbm(indx,albmStrB[1]**);}) ;
}
So can someone advise how to pass the indx variable that each onclick() function would have a unique value ?