selecting root element in jquery

后端 未结 9 778
粉色の甜心
粉色の甜心 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:33

    If you've got your elements as a jQuery fragment like:

    var myElements = $('
    ');

    then you can find the first element by:

    myElements.filter(":first")
    

    The filter function looks from the root element of the fragment.

提交回复
热议问题