How can I read the contents of a text area line by line or split the text in different lines to obtain input as lines of text.
            Asked
            
        
        
            Active
            
        
            Viewed 1.5k times
        
    5 Answers
7
            
            
        Try this one....
you can split by "\n" and then get lilne by line value using for loop
var lines = $('textarea').val().split('\n');
for(var i = 0;i < lines.length;i++){
    //code here using lines[i] which will give you each line
}
        Ganesh Rengarajan
        
- 2,006
 - 13
 - 26
 
2
            
            
        You can achieve it  by  using split() method.
 var splittedLines= inputString.split('\n');
And where splittedLines  is an array.Loop through splittedLines to get the each line.
        Suresh Atta
        
- 120,458
 - 37
 - 198
 - 307
 
0
            
            
        you can convert the value of the textarea to an array by splitting on the newline \n character
        Riv
        
- 1,849
 - 1
 - 16
 - 16