Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
105
rated 0 times [  112] [ 7]  / answers: 1 / hits: 29128  / 12 Years ago, sat, january 5, 2013, 12:00:00
document.getElementById('area').onkeyup=keydown;
function keydown (event) {
if (event.target.id=='area' && event.which==13) {
document.getElementById('arsh').innerHTML+=n;
}
}


Arsh is the ID of my paragraph where i want to add the new line why is this not working can anyone help me ?I just want to add a new line when Enter is pressed in the textarea (ID area) to my Paragraph (ID arsh).



here is the HTML



<textarea ID=area class=in>
Message
</textarea>
<br />
<br />
<p ID=tiesh class=sh>
</p>
<br />
<br />
<p ID=arsh class=sh>
</p>
<br />
</div>


I am basically trying to do it like here in stackoverflow when you press enter in the textarea down the paragraph jumps down a line also.



enter


More From » html

 Answers
5

Using CSS, give #arsh (or any other elements that you want to render new lines) this attribute.



white-space: pre-wrap;

[#81059] Friday, January 4, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kenyonmasonc

Total Points: 44
Total Questions: 117
Total Answers: 116

Location: Morocco
Member since Fri, May 22, 2020
4 Years ago
;