anam
anam

Reputation: 3913

Add new line while concatenating variable string

In an array variable, I am concatenating 2 variables and then storing it in an array .I want to add a linebreak between two variables. I tried \n and it is not working .

 var arrBackImg = new Array();
 var  frontText = new Array();
 for(......){
     frontText[i] = title+"\n"+description;
     backText[i]=title+":"+longdesc;
  }

how to add new line character in this variable???

Upvotes: 2

Views: 13664

Answers (3)

GautamD31
GautamD31

Reputation: 28763

you can try like

frontText[i] = title+"<br>"+description;

BUT *you should put that value as html like*

$('#txt').html(frontText[i]);

Upvotes: 4

som
som

Reputation: 4656

Use <br>

frontText[i] = title+"<br>"+description;

Upvotes: 2

Jude Duran
Jude Duran

Reputation: 2205

Try using <br>

  var arrBackImg = new Array();
  var  frontText = new Array();
    for(......) {
      frontText[i] = title+"<br>"+description;
      backText[i]=title+":"+longdesc;
    }

<br> is the tag used for line breaks in HTML

Upvotes: 1

Related Questions