selecting root element in jquery

后端 未结 9 792
粉色の甜心
粉色の甜心 2021-01-18 04:06

I need to be able to select the root element from a fragment without knowing the node types, class, id or hierachy.

9条回答
  •  死守一世寂寞
    2021-01-18 04:44

    If you want to select the top level parent of an element but still under the body, I'd go

    $(obj).parents().filter('body > *')
    

提交回复
热议问题