jQuery parent of a parent

前端 未结 9 1560
执笔经年
执笔经年 2020-12-02 05:40

I am currently trying to find the parent of a parent of an element. I have a link being clicked that is in a , and I\'d like to get the

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 06:30

    That should work... you might try

    $(this).parents(':eq(1)');
    

    The .parents(selector) says get all ancestors that match the selector

    and the :eq(1) says find the oneth (zero-indexed, so the second) element in the list

提交回复
热议问题