Brandon schrieb:
I am finishing up a small script using the jQuery library, and I am
struggling with a onclick function:
for (i=0; i<elements.length; i++) {
$('#'+settings.instancename+'-nav-'+String(i+1)).click(function() {
jumpTo(i);
});
}
Now I know what the problem is, when I call to the function jumpTo(i),
it passes i as a reference (every click ends up as 5, which is the
last value of i). How can I pass the value of i, and not the
reference of i?
Oh, or just use jQuery.each:
jQuery.each(elements, function(i, value) {
$('#'+settings.instancename+'-nav-'+String(i+1)).click(function() {
jumpTo(i);
});
});
--
Jörn Zaefferer
http://bassistance.de