views:

207

answers:

2

How would you go about breaking up a textarea value into an array, based on the end of line separation? Use of jQuery is cool by me...

+1  A: 

This should work (tested in Firefox and Google Chrome):

var arrayOfLines = $('#textAreaID').val().split('\n');
Daniel Vassallo
It should be `$('#textArea').val().split('\n')`, the jQuery object doesn't have a `value` property.
CMS
@CMS - or even $('#textArea')[0].value.split('\n') :)
Russ Cam
@CMS: Oops. Thanks for noting.
Daniel Vassallo
$('#textArea').val().split('\n') did the trick
Matrym
+1  A: 

var txtarea = document.getelementbyId('textarea');

var stringarray = txtarea.value.split('\n');

Eric