I\'m using jquery, and I have a textarea. When I submit by my button I will alert each text separated by newline. How to split my text when there is a newline?
Try initializing the ks variable inside your submit function.
ks
(function($){ $(document).ready(function(){ $('#data').submit(function(e){ var ks = $('#keywords').val().split("\n"); e.preventDefault(); alert(ks[0]); $.each(ks, function(k){ alert(k); }); }); }); })(jQuery);