See my code:
var ths = $("#my_table table th");
if (ths.length > 1) {
var $th = ths[1]; // tried here plain 'var th' - still got error
th.find('#map_column_element_id'); // error here!
}
I get array of JQuery objects. Then I try to manage the second element as JQuery object. When I issue
th.find(...)
I get TypeError: th.find is not a function. What am I doing wrong?
You’re getting the native JS DOM element, which doesn’t have a
find()method. Useeq(), or rewrap the element with$(ths[1]).I’d use
eq(), like so:Also agree with Andrew in the comment, an ID is unique, and there should be no need to
find()it, simply doing$('#map_column_element_id')should suffice.