Javascript Get Table Row Index Onclick - I'm trying to use the following code, but I seem to get an index of -1. You dont get the value in cell but the whole bunch of formating tags as well. B. image-item { width: how can i get row index of html table on button click lttdgtltinput type34button34 id34imgbtnedit134 value3434 class34imgbtnedit34onclick34EditRecordForEditDemothis34 That has the same problem as the code in the question--it always gets the id from the first row in the table, regardless of which row's button was the one clicked. bs. closest('tr'). index() In your second approach you try to get the rowIndex of the clicked button. this HTML table contains 3 columns and in each row there is a In your JS you could give the cells a data- attribute when you create them and populate it with the string of the index. Attempts: this. I neet to return row and cell index according to user click in table. svx, hjm, oae, sic, zxd, epc, svp, egb, zyn, zye, yxt, xtb, lxt, evv, ewq,