I'm using JavaScript in Angular to automatically add new rows to a able when a function is called, this is done after the HTML has already loaded.
In each row of the table there is a cell containing a button.
I would like to use jQuery on the dynamically created buttons but since they are not part of the initial HTML the jQuery function is never called.
I tried using all of the Angular lifecycle hooks to see if any of them would work, but none do.
This is an example of the jQuery I would like to run when the button is clicked:
$( ".deleteButton" ).on("click",function() {
alert("this is a button button");
});
and this is the JavaScript of how my buttons are created
var deleteButton = document.createElement('button');
deleteButton.innerHTML = 'Delete';
deleteButton.type = "button";
deleteButton.className = "deleteButton";
cell4.append(deleteButton);
table.append(row);
I would greatly appreciate any help regarding this!