-3

i am trying to put this in a text area with the id registers and though i tried many ways i was unable to get a new line in the text area

    var r0=0,r1=0,r2=0,r3=10;
    $('#run').click(function(){

         ;

         $("#registers").html('Register 3:'+r3+ '<br>' + 'Register 0:'+r0 );
        

    });

and this is the out put i get in the text area

Register 3:10<br>Register 0:0
U r s u s
  • 6,680
  • 12
  • 50
  • 88

3 Answers3

0

Can't just this be done:

$("textarea").val('Register 3:' + r3 + '\n' + 'Register 0:' + r0);

\n is used to place a new line characters in the strings especially.

Jai
  • 74,255
  • 12
  • 74
  • 103
0

Use html entity of new line &#10;

$("#registers").html('Register 3:'+r3+ '&#10;' + 'Register 0:'+r0 );

or \n

$("#registers").html('Register 3:'+r3+ '\n' + 'Register 0:'+r0 );
Ranjith
  • 2,779
  • 3
  • 22
  • 41
0

Use this code. i have added \n instead of
.

 var r0=0,r1=0,r2=0,r3=10;   
$('#run').click(function(){
     ;

     $("#registers").html('Register 3:'+r3+ '\n' + 'Register 0:'+r0 );


});
Vel
  • 9,027
  • 6
  • 34
  • 66