Below is how my edit and delete links are generated
function getRecords(){
$.getJSON( "viewcustomers.php", function(data) {
var items = [];
var xTd = '';
var xTr = '';
$.each(data, function (key, val) {
var c=0;
var id=0;
$.each(val, function (key1, val1) {
if(c == 0) {
id = val1;
}
c++;
xTd += '<td>' + val1 + '</td>';
});
xTd += '<td><a href="customers.php?update='+id+'" id="update">Edit</a></td>';
xTd += '<td><a href="customers.php?delete='+id+'">Delete</a></td>';
xTr = '<tr>' + xTd + '</tr>';
items.push(xTr);
xTd = '';
xTr = '';
});
$("#records").append(items);
});
}
Now as you can see i have used id=update in my Edit url.
Now after the record is correctly appearing on my page i am trying to run a code when my edit link is clicked .
// Update existing customer
$("#update").click(function(){
alert("working");
});
The above piece of code is not working. I have tried placing it inside the document.ready as well as outside but nothing worked.
Can anyone tell me what is wrong here?