2

Possible Duplicate:
how remove wordwrap from textarea

I have a text area :

<textarea id="areaTL" style='width:700px; height:400px;></textarea>

and I'd like to do a newline only when there is a \n into the text, so the horizontal scroll should be larger than the max text inside the textarea.

Tried with :

overflow: scroll; wrap="off"'

but seems it doesnt works. I'd like to do it for Chome/Firefox and IE7+.

How can I do it?

EDIT

Using white-space:nowrap; as suggested I get this working, but if I do :

textArea=$('#areaTL').val().split('\n');

I get only 1 element in the array, not N. Why?

Community
  • 1
  • 1
markzzz
  • 47,390
  • 120
  • 299
  • 507

2 Answers2

6

I believe white-space:nowrap; is what you're looking for instead of wrap.

ayyp
  • 6,590
  • 4
  • 33
  • 47
  • Here's a fiddle with it: http://jsfiddle.net/EkwgM/ – ayyp Aug 03 '11 at 20:57
  • But after there is a problem with this. If I set white-space:nowrap; and I do `textArea=$('#areaTL').val().split('\n');` I'll get only 1 line on my array. Why? – markzzz Aug 03 '11 at 21:01
  • This works with Webkit, but not in Firefox 5. – Shi Aug 03 '11 at 21:02
  • You'd somehow have to find the `\n` while the content is being typed and then append a `
    ` after it.
    – ayyp Aug 03 '11 at 21:03
0

try this it should work

<textarea cols=100 rows=5 wrap='off'>
Kishore
  • 1,914
  • 1
  • 15
  • 22