I thought this would be simple but this code outputs my spans on the same line.
$("<p/>")
.append($("<span/>", {
class:"time",
text: content.time }))
.append($("<span/>", {
class: "content",
text: content.message
}));
But since it append these elements without a newline, my spans end up needing manual spacing, which just isn't possible at my current scale.
<p><span class="time">now</span><span class="content">Lorem Ipsum ...</span></p>
How can I force jQuery to manually append my spans on a new line? I've tried using .after
to.
EDIT:
I guess I was a bit unclear, so far .append("\n")
is what I'm looking for, if there are any better ways, I'm all ears but appending a <br/>
tag is definitely not what I was looking for.
<p>
<span class="time">now</span>
<span class="content">Lorem Ipsum ...</span>
</p>
too. Why do you expect append to insert any whitespace or BRs by itself? – mplungjan Jul 16 '15 at 20:38