I tried to bind alert on my buttons:
for(var i=1; i<=3; i++){
$('#' + i).live('click', function(){
alert(i);
});
};
It is my html code:
<input id="1" type="button" value="one">
<input id="2" type="button" value="two">
<input id="3" type="button" value="three">
But I get 4 on all buttons. How to fix it to get correctly alert values? (1, 2, 3 and etc..)
Note that you are using
.livewrong, the point is not to bind to each element individually, but to figure out what each element have in common and use that selector: