As to the position of element relative to the parent?

the <tr >
 <td> 
opel
</td>
<td>mazda</td>
<td>audi</td>
 </tr>

for example how do I get the position of the table rows when clicking on a specific td tag?
i.e. opel // 1
mazda//2
audi //3
April 7th 20 at 15:21
2 answers
April 7th 20 at 15:23
Solution
document.querySelector('table').addEventListener('click', function(e) {
 if (e.target.tagName === 'TD') {
 const index = e.target.cellIndex;
console.log(index);
}
});

If this is you, we are talking about table cells. In the more General case, you can do so:

const index = [..., element.parentNode.children].indexOf(element);
April 7th 20 at 15:25
Solution

Find more questions by tags JavaScript