var lines = $('textarea').val().split('\');for(var i = 0;i < lines.length;i++){ //code here using lines[i] which will give you each line} var lines = $('textarea').val().split('\');for(var i = 0;i < lines.length;i++){ //code here using lines[i] which will give you each line}