即时尝试在这里做的是获取单击函数上的表的id,然后当我单击删除按钮时,它会得到该id并将其删除。将变量从一个Jquery函数传递给另一个
$("table tr").click(function() {
var id;
$(this).removeClass('table-hover');
$(this).css("background-color", "#4682B4");
id = $(this).find(".id").html();
alert("Are you sure you want to delete data with id = " + id); //using just to check if its getting the id of the row
});
$('.btnDelete').click(function() {
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: 'POST',
url: 'EmployeeDelete',
data: JSON.stringify({ id: id }),
success: function (data) {
}
});
});
我在做什么错在这里
你存储的ID表的TR它被认为是固定的吗? –
即时获取tr的id并将其保存到var id –