I suspect that your problem is pretty much a "classic" one. The problem is that each of the function objects you create will share the single loop variable "i" between them. In other words, your functions are written as if they each get a distinct copy of "i", but in fact they do not. Thus each one of your "click" handlers will in fact operate on the div corresponding tothe last value of "i" when the loop ran.
Try wrapping your click handler in another layer of function, and pass that function the value of "i". Then each of your closures will have their own copy. ... .click((function(i) { return function() { // your code here })(i)); On Sat, Sep 5, 2009 at 9:00 AM, Matt_pl<mateuszzywi...@gmail.com> wrote: > > Hi, > > I wrote simple click function to load big images from thumbs and it > works properly. > I put this into for loop because i need to make few galleries on one > page. The point is to connect right thumbnails set with right .big-img > div. > > Here is the code http://paste.pocoo.org/show/138171/. > > Maybe someone can help because i am a "fresher" with jquery. > -- Turtle, turtle, on the ground, Pink and shiny, turn around.