$parserHTML(string, applyto, method = "append", scriptMethod = "after")
Description: Parses an HTML string, extracts scripts, and injects HTML content into the DOM.
Parameters:
string
(String): The HTML string to be parsed and injected into the DOM.applyto
(HTMLElement): The target element or container where the parsed HTML content will be injected.method
(String, optional): The method used to inject the parsed HTML content into the target element. Default is "append"
."textContent"
, "innerHTML"
, "append"
, "appendChild"
, or any other valid method.scriptMethod
(String, optional): The method used to inject extracted scripts into the DOM. Default is "after"
.
"append"
, "after"
, "before"
, "prepend"
, or any other valid method.Usage:
$parserHTML('<div>Hello, world!</div>', document.body, 'append', 'after');
applyto
element using the specified method
.scriptMethod
.applyto
element exists in the DOM before calling this function, or unexpected behavior may occur.