There are other questions about append, but this is specifically about tag order. The function works fine for content, but seems to close tags before it opens new ones. In this code the words are placed correctly but the p tag is not within the span tag.
html:
<div></div>
js:
$(document).ready(function () {
$("div").append('<span>begin');
$("div").append('<p>middle</p>');
$("div").append('end</span> ');
});
I want to use a loop to create multiple p's inside the span, how can I get around this?
Edit: http://jsfiddle.net/dpXv2/3/ This should be a little clearer, and I removed the p tag.
middle
end');`. And again, `p` cannot be child of `span` – Jashwant Jul 18 '14 at 17:12