I have a problem with binding functions from an array to some elements, but i get this error after i click on any element with class "class".
Uncaught TypeError: Property '4' of object function (){alert(1)},function (){alert(2)},function (){alert(3)},function (){alert(4)} is not a function
var c = [
function(){alert(1)},
function(){alert(2)},
function(){alert(3)},
function(){alert(4)}
];
function test(b){
for(var i = 0; i < b.length; i++){
$('.class').eq(i).bind('click', function(){
b[i]();
});
}
}
test(c);
I think that the variable i keep its last value.
any solution or explanation will be really appreciated. Thanks in advance.