I have below function:
$(".import-shipments").on("click", function(){
var sendinger = $('#shipments').val().split("/\n/");
for(var i = 0; i < sendinger.length; i++){
console.log(sendinger[i]); //This returns 3 lines
addRow(i,"#rows") //It only adds 1 line
}
});
Which takes the values in my textarea, and count each value per line.
I then have below function, which should append a new "row", for each value:
function addRow(id, element){
var row = '<div class="row">'+
'<div>#'+id+'</div>'
'</div>';
$(element).append(row);
}
The problem is, that above only appends one row, when it should append 3.
Please see this jsFiddle for an example on how above works.
What I want to do is, for each line in the text area, it should also run the addRow() function for each line.