Hello!

There is a table, there are several rows of data in it, each row has a title attribute with the row number in the table, as well as in this row there is a button for adding a row below:

<table class="data_sheet"> <tr class="headers"> <td nowarp>№</td> <td nowarp>Изменить</td> </tr> <tr class="content" title="1"> <td> <p>text</p> </td> <td> <p class="button" onclick="addPosition();" title="1"> Добавить </p> </td> </tr> </table> 

After adding a row, the onclick attribute changes to rmRequest , this function should delete the entire string when the button is pressed.

The question is: how to find out which button was pressed to delete a row?

    1 answer 1

    Here's a sample code: https://jsfiddle.net/zudjk8yt/1/ Instead of the onClick attribute, it’s better to work with the class. Just in case I will give the essence of the example. In case it disappears with jsfiddle

     $('.add-position').click(function(){ $(this).closest('tr').remove(); }) 

    And in the table itself, the onClick article is removed and instead of it, to the element on which we will click we add an arbitrary class, which we create in js. In this case, it’s an add-position.