Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return All Elements in a Table Column Using jQuery

I have an HTML table where each row represents a company and each column represents a year.

Returning a collection of all the cells in a row will be easy. I could give the row an ID or class and look for all the <td> elements within that row. But how would I get all the elements that correspond to a particular year (column)?

I was thinking I could make up element IDs using the company and year values (e.g. item_1234_2011). This would make it possible, given an element's ID, to determine that elements corresponding company and year IDs. But how would I locate all the elements associated with a given year?

like image 495
Jonathan Wood Avatar asked Feb 01 '26 05:02

Jonathan Wood


1 Answers

Doing something like this $('td[id$=_2011]'); comes to mind, if you use the format you specified.

like image 184
anson Avatar answered Feb 03 '26 17:02

anson