tags:

views:

74

answers:

2

Ex : document.write("\n");

I want to print that \n in my <textarea>.

+4  A: 
document.write("\\n");

That will put a "\n" in your text area.

Borealid
this answer should be marked wow.......... though i asked the wrong question ...i was suppose to ask this in c language
subanki
@subanki: Regardless, you should probably mark this answer as accepted.
Dolph
yes surei will
subanki
+2  A: 

The \ starts an escape sequence (for a new line), so you have to escape it to get a literal slash.

"\\n"

For a textarea, you just write that between <textarea …> and </textarea> (if you are writing the whole thing with document.write or reference_to_textarea.value = "\\n" if you are setting it after the element exists in the DOM.

David Dorward
it s correct too
subanki