I am trying to wrap a created series of elements that are created on the fly with another element, for example:
var innerHtmlAsText = "<li>test1</li><li>test2</li>";
var wrapper = "<ul />";
$("div#target").append($(innerHtmlAsText).wrapAll(wrapper));
Expected Result
<ul>
<li>test1</li>
<li>test2</li>
</ul>
But the actual result:
<li>test1</li>
<li>test2</li>
Items are linot wrapped. In my case, innerHtml is generated on the fly from a user-created template, and the wrapper is provided separately. How can I get the internal values?
source
share