jQuery Rocks! – Selecting all of the text from a table column
January 11, 2011
On occasion it is nice to be able to select and copy the contents of a column from a table element. Using jQuery, this is a simple task that takes advantage of the following jQuery features: Event Handling - for the double-click of the column header Selectors - to determine which DOM elements to process Traversing - start from a TH that is double-clicked and find which column of the table it represents, then find all of the column TDs Iteration - process each of the TDs in a column Attributes - get the text for each TD, and change the TD's Class With a standard-format table, it is easy to add an event handler to the header TH element. Click here to view a simple example of a such a table. It has a header and a body, and has…