selecting root element in jquery

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

    I get html fragment from ajax call, and I also need to get the root div from it. What I did was simply call $(data), and jQuery will parse the returning text as HTML and give you the root.

    $.ajax path,
      type: 'GET'
      contentType: 'application/x-www-form-urlencoded;charset=UTF-8'
      success: (data) ->
        $(data)
    

提交回复
热议问题