The task is that I am trying to pass the resulting value in this case to the number 1 1 1, the data values are contained in this line in the code $('#res').append(' '); then I try to pass this value to a function that accepts parameters and saves this value to a file, a line
var csvData = 'data:application/csv;charset=utf-8,' + $('#res').append(' '); As soon as I insert the line $('#res').append(' ') the following [objectObject] is written to the file, but I make an error when I try to write on js and jquery in one place. Tell me how to make the values 1 1 1 which contains this line $('#res').append(' ') fall into the file
function recalculate(){ $('#res').text(''); var sum = 0; $('div').each(function(){ var selectVal = $('select',this).val(); $('#res').append(selectVal); if($(this).index() < $('div').length - 1){ $('#res').append(' '); //содержит значения 1 1 1 } sum +=selectVal * 1; }); $('#res').append('<p>Согласовано: ' + sum + ' </p>'); document.getElementById('tfa_src_data').onclick = function() { var csv = JSON.stringify(localStorage['savedCoords']); var csvData = 'data:application/csv;charset=utf-8,' + $('#res').append(' '); this.href = csvData; this.target = '_blank'; this.download = 'filename.txt'; }};
#reselement? - Grundy