How to find the id of the html while looping through <tr> in javascript/jquery

Viewed 75

I'm working on a queue management page where we have multiple Html tables on a single page and each table holds 10 values including name and image, now I wanna remove a row from the table when the present button is pressed and I did it using this following code

function removePresent() {
               
    const urlParams = new URLSearchParams(window.location.search);
    const HallNo = urlParams.get('hallno');
    const TvIP = urlParams.get('tvip');

    $.ajax({
        url: '@Url.Action("PresentDisplayRemover")',
        type: "GET",
        data: { 'HallNo': HallNo, 'TvIP': TvIP },
        contentType: "application/json",
        success: function (response) {

            $.each(response, function (j, e) {
                const rows = Array.from(document.getElementsByTagName('TD'));
            $.each(rows, function (i) {
                if ($(rows[i]).text() === e.StudentId) {
                    $(rows[i]).parent().remove();
                }
            });
        }
   });
}

Now my flow also requires me to find the Id of the matched to increment a counter, I have no idea how to do it and I also tried searching online but I ended up finding nothing,I'm relatively new to js and jquery since my main workflow only consists of me working with .NET so any help would be great, Thank You.

0 Answers
Related