it's not possible to loop .click function (To create multipple buttons)
- by user1542680
Im Trying to create multiple buttons that each one of them doing something else.
It working great outside of the "each" loop, But in the moment I'm inserting the .click function in the .each function it doesn't work...
Here is the Code:
$.each(data.arr, function(i, s){
html += '<div id="mybtn'+s.id+'"><button class="first">Btn1</button><button class="second">Btn2</button></div>';
var btnclass="#mybtn"+s.id+" .first";
$(btnclass).click(function(){
//do something
});
});
Please Let me know what is wrong...
Thank you very much!!!
Eran.