This all works fine. Then I try to bind events to them. When done manualy like this:
the Click alerts the right value (3 or 4). All is fine.
But as soon as I put this inside a For-loop:
- for( var index = 3; index < 4; index++ ){
- $(document).on("click", "#veld_" + index, function(){ alert( index ) });
- }
it works the same but alerts at each field the last value for index ( 5 in this example ). I also tried
- $("#veld_" + index).click(function(event){ alert( index ) });
With the same result.
Please help!!!