showing results for - "how to give id dynamically in javascript"
Edward
22 Oct 2019
1//Here the delete button gets a unique ID everytime, the ID is the array index of the element. 
2array.forEach(function (element, index) {
3      display =
4        display +
5        `<tr>
6            <th scope="row">${index + 1}</th>
7            <td>${element.first}</td>
8            <td>${element.second}</td>
9            <td>${element.third}</td>
10            <td><button type="button" id="${index}" onclick="deleteNode(this.id)" class="btn btn-danger">Delete</button></td>
11        </tr>`;
12    });
13