gpt4 book ai didi

jquery - 使用 jquery 解析 HTML

转载 作者:行者123 更新时间:2023-12-01 00:43:34 26 4
gpt4 key购买 nike

假设在变量 html 中保存如下

var vhtm="<div><div id='test'>zebra</div><div id='foo'>here is my many other html content</div></div>";

我想在jquery的帮助下解析存储在变量中的上述html。我需要通过 id 提取特定的 div 并包括其内容。返回结果如下

<div id='foo'>here is my many other html content</div>

所以我需要通过 id 来查找 div,例如 id='foo'

请帮我如何像jquery一样解析上面的内容。

最佳答案

尝试这样的事情:

$(vhtml).find('#foo');

关于jquery - 使用 jquery 解析 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7104187/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com