Given some text and a html structure, how can I create a new html fragment where the structure is wrapped around the text?
Example:
text = "mytext"
html = "<div><p><span></span></p></div>"
Desired result:
newHtml = "<div><p><span>mytext</span></p></div>"
If possible, using pure jquery, without parsing html manually. Note that "text" is a literal string, not a text node in a document.
Of course, the code I'm looking for should work with arbitrary html, not just with the example above.