First things first, you cannot create multiple elements inside a single DOM with duplicate IDs. Your HTML will be invalid if multiple buttons contain the same ID (update, edit, etc.). That will break any JavaScript logic that you write.
Quote:
If I just need to edit the information in a row
Simplest option would be to pass the row number (maybe the ID of the current record, number of row, object information;
if you are using a framework to render UI from a data set) to the function.
I would change the button creation code to something like this in HTML:
<button type="button" id="edit-row1" onclick="handleEdit('row1')">Edit</button>
Then in JavaScript, handle the situation like this:
function handleEdit(row) {
}
This is one way to control the row and update it.
My suggestion? I would recommend that you invest some time in a UI generation framework. If React or Vue.js sounds too complex, you can invest in jQuery UI for time being and use their controls to perform these actions.
See this:
DataTables example - jQuery UI[
^].