Navigate a rootless dom with JQuery

后端 未结 4 1971
借酒劲吻你
借酒劲吻你 2021-01-21 07:04

Given this html string:

var string = \"

\";

I create a jQuery object with it:

var dom          


        
4条回答
  •  花落未央
    2021-01-21 07:44

    When there's no root element you'll need to use filter() to get top level elements:

    var string = "

    "; var $dom = $(string).appendTo('body'); // appendTo() is only for purposes of this demo $dom.filter("p").text('hello world!');

提交回复
热议问题