How do i add line breaks to Javascript variables that are displayed in a <div> ?

Hello,

I'm trying to add line breaks, currently using '\n', to make each variable i display in a <div> appear on a new line. At present my code looks like the attached.

The line breaks do not occur - what am i doing wrong?


Many thanks
<div id="infolinks">' + flag_folder.flag + '<b>At the time i visited...</b>\n' + '<b>Language: </b>' + language + '\n <b>Currency: </b>' + currency + '\n' + '<b>Exchange Rate: </b>' + exchange + '\n' + '<b>Plug Type: </b>' + plugtype + '\n' + '<b>Religion: </b>' + religion + '\n' + '<b>Head of State: </b>' + headofstate + '\n' + '<b>Population: </b>' + pop + '\n' + '<b>Per Capita Income: </b>' + pci + '\n' + '<b>National Dish: </b>' + food + '\n' + '<b>National Day: <\b>' + nday + '\n' +'</div><div id="infofooter">I was here on the ' + date + '</div>

Open in new window

DaniishAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
intead of \n you need to use the html break tag:
<br />

Open in new window

0
MMDeveloperCommented:
the \n should only put a line break in the code, not in the display... you'd need to replace them with <br /> to line-break the HTML display
0
hieloCommented:
try:
'<div id="infolinks">' + flag_folder.flag + '<b>At the time i visited...</b><br />' + '<b>Language: </b>' + language + '<br /> <b>Currency: </b>' + currency + '<br />' + '<b>Exchange Rate: </b>' + exchange + '<br />' + '<b>Plug Type: </b>' + plugtype + '<br />' + '<b>Religion: </b>' + religion + '<br />' + '<b>Head of State: </b>' + headofstate + '<br />' + '<b>Population: </b>' + pop + '<br />' + '<b>Per Capita Income: </b>' + pci + '<br />' + '<b>National Dish: </b>' + food + '<br />' + '<b>National Day: <\b>' + nday + '<br />' +'</div><div id="infofooter">I was here on the ' + date + '</div>'

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.