Javascript: Convert textarea into an array
问题 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: This should work (tested in Firefox and Google Chrome): var arrayOfLines = $('#textAreaID').val().split('\n'); 回答2: var stringArray = document.getElementById('textarea').value.split('\n'); 回答3: Cross-platform way: var area = document.getElementById("area"); var lines = area.value.replace(/\r\n/g,"\n").split("\n"); 回答4: You could try this function :