How does jquery get the line in which the button is currently clicked, and then delete it

using datatable, I want to click the delete button to delete the current line, but when I delete it as follows, only the first time I get the DOM element is the current line. After a few more clicks, I get the DOM of other lines, and how to just get the current line.

t.row($(e).parents("tr")).remove().draw(false);

clipboard.png


clipboard.png
clicking the delete button once will console the values of multiple rows or even console. multiple times

the problem should be

$("-sharpdelete").click(function () {
        $("-sharpdeleteModal"). modal("hide");
        deleteTr(e);
        for(let s of statusList){
            if(s["tableId"]===tableId){
                statusList.remove(s)
            }
        }
    })

in this click event, if it is outside this event, there is no problem at all, and that will be the case if it is written in this event.


The

event is bound repeatedly. Without running the removeStatus function once, $("- sharpdelete"). Click ) is bound once. You can put the binding code of this event outside, or unbind

first.
$("-sharpdelete").unbind('click').click()

your click event is bound repeatedly. Every time you trigger removeStatus, you bind $("- sharpdelete") to $("- sharpdelete"). The more click, triggers, the more click, and will not overwrite the last one, so you have to
$("- sharpdelete"). Unbind ("click") .click (xxxxx)

.
Menu