javascript - jquery function not catching dynamically generated id -
i have table rows generated ajax query response like:
var inp = '<input id="new_po_qty" style="text-align:center" type="text" value="1">'; $('<tr id="new_po_item_row">').html('<td style="text-align:center">' + sku_id + '</td><td style="text-align:center">' + inp + '</td><td id="new_po_cp" style="text-align:center">' + cost_price + '</td><td id="new_po_total_cp" style="text-align:center">' + cost_price + '</td>').appendto('#new_po_body');
now wrote jquery function catch changes on inp
variable in table row. jquery function not catching changes in input box.
jquery function:
$('#new_po_qty').on('change paste', function(){ alert('changes made.'); $.niftynoty({ type:"primary",icon:"",title:"start adding products.",container:"floating",timer:5000 }); });
what doing wrong function?
use event delegation:
$(document).on('change paste', '#new_po_qty', function(){ alert('changes made.'); $.niftynoty({ type:"primary",icon:"",title:"start adding products.",container:"floating",timer:5000 }); });
see jquery .on()
docs.
Comments
Post a Comment