I have a 10 X 8 table.
every row has 8 columns ie.., 8 td elements. Each td in the row has a different class. Is it possible to get the info of 1st td element in the row, when i click on any of the other td’s in the row.
Basically i am creating a jquery onclick event on the column 2 to column 8 of each row. When i click on any of this column(td) it should get the info ie.., either id or class or name attribute of the column 1. I needs this one to send it on the server side code.
—
Thanks.
Yes. From the clicked element, you navigate up to the row via
closest, and then you can find thetdwith the relevant class withfindorchildren(probablychildrenin case you have nested tables):Or if you always want the first
td:That handler will work if it’s assigned to any
tdin the table, to thetr, or indeed to thetbodyortableas a whole.Live Example | Source
JavaScript:
HTML: