I want to achieve the following:
Let say I have ten buttons on my page, and they all are dynamically generated. I have added ID to all of these ten buttons, say id be 1,2,3....10. using the following code.
function createButton(id){
button.setAttribute("name", id);
}
Now I want to add 'onlick' event to all these button, like this
function abc()
$(document).on('click','#1', function(){
callSomeFunc();
});
This way I'll have to write the above code 10 times with different Id's. I tried to use loop over the function as
function abc()
for(var i=1, i<=10, i++){
$(document).on('click',id, function(){
callSomeFunc(id);
});
}
to no avail ! How can I achieve this ?