I'm trying to set click actions on some generated jQuery buttons. But in my code I think is something wrong because if I click on any of the buttons console.log(buttonid) will display #btn170, which means the last button(data.incidentList.length). What is curious, the following line $(buttonid).css( "border", "3px solid red" ) seems to work ok, all the buttons are red borders.
for(var j=0; j<=data.incidentList.length; j=(parseInt(j)+parseInt(itemInterval))) {
var buttonid = '#btn'+ parseInt(j+1);
$(buttonid).css( "border", "3px solid red" );
$(buttonid).click(function () {
console.log(buttonid);
});
}