websss
asked on
On click event for dynamically generated html - not working
Hi
I have a table with an ADD ROW button, when i click this button is creates a new row dynamically
I then want to have a click event fire for one of these newly created html elements: <input id='schemeItemSaveLink' type='button' value='save'>
however, the alert: alert('you clicked me again!'); isn't firing
What am i doing wrong?
I have a table with an ADD ROW button, when i click this button is creates a new row dynamically
I then want to have a click event fire for one of these newly created html elements: <input id='schemeItemSaveLink' type='button' value='save'>
however, the alert: alert('you clicked me again!'); isn't firing
What am i doing wrong?
$('#addSchemeItemRow').on('click', function () {
var addRow = "<tr class='schemeItemRow'><td> <input type='text' name='lower' id='txtLowerThreshold'> </td><td> <input type='text' name='upper' id='txtUpperThreshold'> </td><td><input type='color' id='schemecolor' style='width: 25px; height: 25px;'></td> <td><input id='schemeItemSaveLink' type='button' value='save'></td></tr>";
//add current row to table
$('#schemetable tr:last').after(addRow);
});
$("#addSchemeItemRow").on("click", "#schemeItemSaveLink", function () {
alert('you clicked me again!');
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome.
ASKER