jQuery: get parent, parent id?

后端 未结 3 1076
离开以前
离开以前 2020-12-02 21:44

How can I get the id of the ul (myList)

3条回答
  •  情歌与酒
    2020-12-02 22:31

    $(this).parent().parent().attr('id');
    

    Is how you would get the id of the parent's parent.

    EDIT:

    $(this).closest('ul').attr('id');
    

    Is a more foolproof solution for your case.

提交回复
热议问题