I have looked though all the historic answers to this question but nothing seems to be working for me
When a button is clicked on my page , A div box becomes visible and a table is added
$('#NewParentItem').click(function() {
InnerTable = "<table width='90%' bgcolor='#CCCCCC' align='center' >"
InnerTable += "<tr height='12px'> "
InnerTable += "<td width='2%'></td> "
InnerTable += "<td width='68%' style='text-align:center' > <input type='text' name='Item' placeholder='Main Item Name' size='12'> </td> "
InnerTable += "<td width='30%'> <button type='button' id='NewParentSubmit' value='generate new element' >Enter </button> </td> "
InnerTable += "</tr> </table>"
DisplayUniDiv(160,200,50,200) // display div box
$('#UniDivHead').html("Add New Main Group Item (Parent)")
$('#UniDivBody').html( InnerTable )
}) ; // End of Function `
This table now includes a button with the id NewParentSubmit
Further within my script I have the following
$(document).on('click', '#NewParentSubmit' , function() {
alert(" Submit ")
}) ; // End of Function
I would now expect this to trigger( after the button has been dynamically created ) when the user clicks the button , But nothing is happening ?
All these functions are contained within
$(document).ready(function() {
});
Can anyone offer a solution or some suggestion please ?
Thanks