这里我想要Bind Id值来点击Event.When我点击Edit链接它的Hit Hello功能
$('#Btn2').click(function () {
$.ajax({
url: "http://localhost:44509/api/Stored/GetEmployee",
type: 'GET',
dataType: 'json',
success: function (data) {
var $table = $('<table/>').addClass('table table-responsive table-striped table-bordered');
var $header = $('<thead/>').html('<tr><th>EmpId</th<th>Action</th></tr>');
$table.append($header);
$.each(data, function (i, value) {
var $row = $('<tr/>');
$row.append($('<td/>').html(value.Emp_Id));
$row.append($('<td/>').html("<a href='http://localhost:44509/api/Stored/EditEmp' click='Hello()'" + value.Emp_Id + ">Edited</a>"))
$table.append($row);
});
$('#Div1').html($table);
}
})
})
$('#Hello').click(function () {
alert();
})
答案 0 :(得分:0)
meybe this:
$('#Btn2').click(function () {
$.ajax({
url: "http://localhost:44509/api/Stored/GetEmployee",
type: 'GET',
dataType: 'json',
success: function (data) {
var $table = $('<table/>').addClass('table table-responsive table-striped table-bordered');
var $header = $('<thead/>').html('<tr><th>EmpId</th<th>Action</th></tr>');
$table.append($header);
$.each(data, function (i, value) {
var $row = $('<tr/>');
$row.append($('<td/>').html(value.Emp_Id));
$row.append($('<td/>').html("<a href='http://localhost:44509/api/Stored/EditEmp' onClick='Hello(\'"+value.Emp_Id+"\');'>Edited</a>"))
$table.append($row);
});
$('#Div1').html($table);
}
})
})
function Hello (_in) {
alert(_in);
})