$parserHTML(string, applyto, method = "append", scriptMethod = "after")
描述:解析HTML字符串,提取脚本,然后将HTML内容注入DOM。
参数:
string
(字符串):要解析并注入DOM的HTML字符串。applyto
(HTMLELEMENT):注入解析的HTML内容的目标元素或容器。method
(字符串,可选):用于将解析的HTML内容注入目标元素的方法。默认为"append"
。"textContent"
,,,,"innerHTML"
,,,,"append"
,,,,"appendChild"
,或任何其他有效方法。scriptMethod
(字符串,可选):用于将提取脚本注入DOM的方法。默认为"after"
。
"append"
,,,,"after"
,,,,"before"
,,,,"prepend"
,或任何其他有效方法。用法:
$parserHTML('<div>Hello, world!</div>', document.body, 'append', 'after');
applyto
使用指定的元素method
。scriptMethod
。applyto
在调用此功能之前,元素存在于DOM中,或者可能发生意外行为。