📅  最后修改于: 2022-03-11 15:04:29.083000             🧑  作者: Mango
$(function() {
function numberRows($t) {
var c = 0;
$t.find("tr").each(function(ind, el) {
$(el).find("td:eq(0)").html(++c + ".");
});
}
$("#add-service-button").click(function(e) {
e.preventDefault();
var $row = $("");
$row.append($(""));
$row.append($(" ").html($("#add-service").val()));
$row.append($(" ").html("X"));
$row.appendTo($("#service-table tbody"));
numberRows($("#service-table"));
});
$("#form-entry form").submit(function(e) {
e.preventDefault();
$("#add-service-button").trigger("click");
});
$("#service-table").on("click", ".del-service", function(e) {
e.preventDefault();
var $row = $(this).parent().parent();
var retResult = confirm("Are you sure you wish to remove this entry?");
if (retResult) {
$row.remove();
numberRows($("#service-table"));
}
});
});