jQuery parent of a parent

前端 未结 9 1557
执笔经年
执笔经年 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:05

    If you have any sort of id/class for the parent, you can use parents() but that will give you all parents up to the < body > unless you filter() or stop it some other way like

    $(this).parents('.myClass');
    

    Hope this helps someone :)

提交回复
热议问题