Javascript how to split newline
- by oknoorap
I'm use jquery, and I have a textarea, so when I submit button I will alert every text separate by newline. How to split from newline?
var ks = $('#keywords').val().split("\n");
(function($){
$(document).ready(function(){
$('#data').submit(function(e){
e.preventDefault();
alert(ks[0]);
$.each(ks, function(k){
alert(k);
});
});
});
})(jQuery);
example input :
Hello
There
Result I want is :
alert(Hello); and
alert(There)