Search code examples
jquerycss-selectorsancestor

How to find the first ancestor node whose tag is <tbody> with jQuery?


Suppose the jQuery object is $obj,how to select the desired ancestor?


Solution

  • Use parents() with the :first selector:

    obj.parents("tbody:first");