How to get row data when clicking button which is inside a row using javascript? I am creating a shopping cart with same Addtocart button on each row. as shown in the below table I used a for loop to print each row. I want to access the data of a row in which the button is clicked. How can i do it?