Javascript 从另一个js文件获取datatable行的引用

Javascript 从另一个js文件获取datatable行的引用,javascript,jquery,Javascript,Jquery,下面是删除datatable当前行的代码。此代码位于js文件中,js文件在表所在的html文件中引用 $(document).on('mousedown', '#orders', "td .fa.fa-minus-square", function () { //get the description from the column whose class="description" var description = $(this).closest('tr').f

下面是删除datatable当前行的代码。此代码位于js文件中,js文件在表所在的html文件中引用

$(document).on('mousedown', '#orders', "td .fa.fa-minus-square", function () {       
    //get the description from the column whose class="description"
    var description = $(this).closest('tr').find('.description').text();
   //get the reference 
    var removeItemEl = $(this);
    bootbox.confirm("Are you sure you want to delete this line item?", function (result) {
        if (result) {
            $.ajax({    
                url: "/api/mycontroller?description=" + description,
                method: "DELETE",
                success: function () {
                    table.row(removeItemEl.parents("tr")).remove().draw();
                }
            });
        }
    });
});

这里的问题是$(this)引用没有引用任何内容。如果我将此代码移回html文件,那么它就可以正常工作。如何访问此按钮所在的行

将everywhere替换为$(event.target),但也在第一行中添加事件作为函数参数

...function (event) ...
....

var description = $(event.target)
if ($(event.target) != //--insert desired element here

    //cancel event handling if source is not desired element
    return;

//source is desired element

....

请显示您的html,它可能有助于为您提供最佳答案。当单击该行中的任何内容时,将触发此解决方案。我希望它仅在单击“删除”按钮时触发。还有其他建议吗?在函数或更改选择器中添加限制选项,我将添加一个粗略的示例和当前代码(只是一个粗略的示例)。如果源不是您所需的元素,您可以取消事件处理