javascript - Jquery append() on another line? -


i thought simple code outputs spans on same line.

$("<p/>")     .append($("<span/>", {         class:"time",         text: content.time }))     .append($("<span/>", {         class: "content",         text: content.message     })); 

but since append these elements without newline, spans end needing manual spacing, isn't possible @ current scale.

<p><span class="time">now</span><span class="content">lorem ipsum ...</span></p> 

how can force jquery manually append spans on new line? i've tried using .after to.

edit:

i guess bit unclear, far .append("\n") i'm looking for, if there better ways, i'm ears appending <br/> tag not looking for.

<p>    <span class="time">now</span>    <span class="content">lorem ipsum ...</span> </p> 

if want html element appeneded newline, can insert newline character, \n, using .after() method before appending second span. in doing so, there space between words (since inline span elements respect whitespace in markup).

example here

$("p").append($("<span/>", {     class: "time",     text: content.time }).after('\n')).append($("<span/>", {     class: "content",     text: content.message })); 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -