jquery get father of element

后端 未结 6 2149
攒了一身酷
攒了一身酷 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:39

    Try this:

    $("#id").parent()
    

    My first suggestion #id:parent doesn’t work as :parent selects all nodes that are parent of other nodes (including text nodes).

提交回复
热议问题