var $th = $td.closest('tbody').prev('thead').find('> tr > th:eq(' + $td.index() + ')');
Or a little bit simplified
var $th = $td.closest('table').find('th').eq($td.index());
More Related Contents:
- jQuery how to find an element based on a data-attribute value?
- Why is my jQuery :not() selector not working in CSS?
- Access the css “:after” selector with jQuery [duplicate]
- Wildcards in jQuery selectors
- use jQuery’s find() on JSON object
- Jquery bind double click and single click separately
- jQuery or CSS selector to select all IDs that start with some string [duplicate]
- Toggle Checkboxes on/off
- jQuery select all except first
- Selecting elements with a certain background color
- Does jQuery do any kind of caching of “selectors”?
- How can I detect if a selector returns null?
- jQuery: select an element’s class and id at the same time?
- jQuery attribute name contains
- jQuery :contains selector to search for multiple strings
- Multiple selector chaining in jQuery?
- Efficient, concise way to find next matching sibling?
- jQuery scrollTop not working in Chrome but working in Firefox
- First word selector
- jQuery select by class VS select by attribute
- How to check if an element does NOT have a specific class?
- Find all elements based on ids using regex on jQuery selector
- A cleaner way to select by multiple possible attribute values?
- jQuery: select all elements of a given class, except for a particular Id
- How to select specific form element in jQuery?
- Performance of jQuery selector with context
- Jquery find all ids starting with a string?
- jQuery: using a variable as a selector [duplicate]
- How to use multiple jquery object variables as selectors?
- How do I select an element with special characters in the ID?