jquery get father of element

后端 未结 6 2134
攒了一身酷
攒了一身酷 2020-12-21 06:08

I\'ve got an element which resides inside a div. I\'d like to get the div by the child\'s ID, is this possible? if so how?

Thank you!

6条回答
  •  庸人自扰
    2020-12-21 06:20

    If you are not looking for the immediate parent, you can also use:

    $('#childID').closest("tr");
    

    Where tr is a selector for the parent you're trying to find. This is useful if you aren't sure of the depth of the hierarchy.

提交回复
热议问题