6
I have a list of entries and one of the attributes of that item is a delete button.
By clicking the button I want to know the position of the line clicked inside the list.
When knowing the position I will delete from the array the same value of the posição[i]
removeLinha(element){
//Aqui eu obtenho a 'tr' clicada
let trash = element.parentNode.parentNode;
//Aqui eu removo;
trash.parentNode.removeChild(trash);
}
But before I remove I need to know the position of <tr>
inside <tbody>
to delete in array as well.
NOTE: The big problem is that the method of adding a new line in the DOM it scans an array of objects and puts in the DOM, so I need to know the position of the line to know its position in the array and delete as well.
actually this is coming as argument in the method call there in HTML.
– Bruno Cabral
I’m using a controller class, so if I use this inside it, it selects the class itself...
– Bruno Cabral
"to delete in the array as well" - which array ? was built as ? You can include both the array and the html where the function is called
removeLinha
?– Isac
the array is dynamically populated with a goal that generates an element:
<tr><td></td><td></td><td></td><td></td></tr>
then each item of my array is a row of my table– Bruno Cabral