-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,366
  • 11
  • 47
  • 86

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
  • 72,925
  • 12
  • 73
  • 99
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,739
  • 3
  • 21
  • 38
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
  • 8,656
  • 5
  • 30
  • 63