<html> <head> <script src="http://code.jquery.com/jquery-2.0.0b2.js"></script> </head> <body> <textarea id="search_list"></textarea> </body> </html> <script> $('#search_list').change(function(){ var search_array = $(this).val() alert(search_array) }) </script>
var string = 'my stroka N1\nmy stroka N2\nmy stroka N3'; Array.prototype.forEach.call(string.split('\n'), function (a) { console.log(a); alert(a); });
<!DOCTYPE HTML> <html> <head> <title>example</title> </head> <body> <textarea style="width: 300px; height: 150px;">text1 text2 text3</textarea><br/> <input type="button" value="click me"> <script> var textarea = document.querySelector('textarea'), button = document.querySelector('input'); button.onclick = function () { var myList = textarea.value.split('\n'); for (var i = 0, ln = myList.length; i < ln; ++i) alert(myList[i]); } </script> </body> </html>
<html> </head> <script src="http://code.jquery.com/jquery-2.0.0b2.js"></script> </head> <body> <textarea id="search_list"></textarea> <script> $(document).ready(function(){ $('#search_list').change(function(){ var string = $('#search_list'); var search_array=string.value.split('\n'); $each(search_array,function(key,val){ alert(val) }); }); }); <script>
var search_array=string.value.split('\n');
alert(string.value)