How to remove DOM element after ajax request with unobtrusive-ajax?

1.1k Views Asked by At

In the callback function "OnSuccess",i can't get the element which i've clicked. After click the "Del" button ,i try to remove the "tr" element which one the "Del" button in that i just clicked.how to do this?

2

There are 2 best solutions below

0
On

You can remove it using jquery:

$('#selector').remove();

also check this out:

JavaScript DOM remove element

2
On

I use a combination of $(this) to get the button (or other dom element that triggered it).

Then .closest with the tr parameter to get the row.

Followed by .remove to remove it:

$(this).closest('tr').remove();