Navigate a rootless dom with JQuery

后端 未结 4 2002
借酒劲吻你
借酒劲吻你 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:35

    .find looks inside of the element. In your case though you're creating a div and a paragraph next to one another. Move the paragraph inside the div and your code will work.

    Or you can wrap both of those elements into a third, parent.

    var string = "

    "; var dom = $(string); console.log(dom.find("p"));

提交回复
热议问题