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?
var ks = $('#keywords').val().split("
");
(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)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…