How to find first parent element in jquery

前端 未结 3 750
情歌与酒
情歌与酒 2021-02-14 05:33

Conside below html -

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-14 06:21

    To get the first parent personally I use the following construction:

    var count_parents = $(".element").parents().length;
    $(".element").parents().eq(count_parents - 1);
    

    Hope, it will be helpful for someone.

提交回复
热议问题