I am creating number of buttons depending upon length of records . So number of buttons will change when record will change every time I will run program. Here is my code of it .
for (var i = 0; i < labels.length; i++) {
<button type="button" id='+i+'>'+i+'</button>';
}
It will create buttons 1,2,3,4,5....up-to length of labels. Now problem is that I want to assign them id and onclick. On everyonclick It will pass value to a function which button was press like I will pass 1 if 1st button was pressed and 2 if 2nd button is pressed. How I can do it ? I saw that Question that reported as duplicate question but he is using jquery and not passing any values to new function based on Id (which is my main problem) .