There is a textarea in which I am through $("#text").val(res); write down the text. The problem is that the text starts to be recorded from the second line, as if at first it is <br> . What could be the problem?

 <textarea style="width: 100%; height: 70%; resize: none; border-color: #ffffff; font-size: 20px; color: #000000;" id="text"/> 

Closed due to the fact that off-topic participants Anton Shchyrov , Grundy , aleksandr barakin , iluxa1810 , fori1ton 13 Nov '16 at 7:50 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Grundy, aleksandr barakin, iluxa1810, fori1ton
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • can I have more code? res variable interests - user190134

1 answer 1

Correct the textarea tag itself - there should be a closing </textarea> :

 var res = "some text"; $("#text").val(res); 
 <textarea style="width: 100%; height: 70%; resize: none; border-color: #ffffff; font-size: 20px; color: #000000;" id="text"></textarea> <script src="https://code.jquery.com/jquery-2.0.3.js"></script> 

  • Corrected. The problem remains: ( - antonin14d
  • What do you have in res , maybe something is wrong there? - HamSter 2:55
  • There is definitely something wrong with res - tCode