On Click of delete button is it possible to remove the table row based on the data attribute ?
This is my js code
$(document).on("click", ".deletevideo", function(event) {
if (confirm("Are You Sure to Remove This Video From This PAC?") == true) {
var video_id = $(this).data('videoid');
}
event.stopImmediatePropagation();
event.preventDefault();
return false;
});
3条答案
按热度按时间hpxqektj1#
您可以使用
closest()
遍历需要删除的最多tr
元素。Fiddle
ymdaylpp2#
You need to pass the Index of the
tr
for which you want thedata-attribute
fromBecause there might be multiple rows in the table
OR if you know the ID of the Row.. simply do this
nbysray53#
Adding my two cents following @Satpal's solution.
If anyone using Fetch API then this (Delete) sample might help too.
HTML (Thymeleaf in my case):
JavaScript: