[英]Convert jQuery element to html string
This JS code tries to modify the raw html. 此JS代码尝试修改原始html。 It does that by converting the html to jQuery element, does the modifications on the jQuery element then the part which is not working is converting back to raw html string. 它通过将html转换为jQuery元素,对jQuery元素进行修改,然后将不起作用的部分转换回原始html字符串。
Since .html()
will not work with xml as indicated in the docs 由于.html()
不适用于docs中指示的xml
How can it convert the jQuery back to raw html string? 如何将jQuery转换回原始html字符串? Thanks 谢谢
let jQ = $($.parseHTML(raw_html));
//modify jQ to heart content
console.log(jQ.html()); //<-- undefined
The raw_html raw_html
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
//...
</html>
edit 编辑
Output of console.log($.parseHTML(raw_html));
console.log($.parseHTML(raw_html));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.