This is my code:
$(document).on("click", "#farm_0", function(){
console.log($("#farm_0").attr("my_id"));
});
$(document).on("click", "#farm_1", function(){
console.log($("#farm_1").attr("my_id"));
});
Console shows good values. But when i try use this:
for(var i=0; i < 2; i++)
{
$(document).on("click", "#farm_"+i+"", function(){
console.log($("#farm_"+i+"").attr("my_id"));
});
}
Button's will work, but console shows just the last value or undefinded. What's wrong with that?