I have a problem with an application using ES6. I am creating a table that receives values from a form, but every time I click the button to send the information to the table, it gives the following error.
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
I wonder if anyone can help me.
Code that gives the error:
var campos = [
document.querySelector('#data'),
document.querySelector('#quantidade'),
document.querySelector('#valor')
];
console.log(campos);
var tbody = document.querySelector('table tbody');
document.querySelector('.form').addEventListener('submit', function (event) {
event.preventDefault();
var tr = document.createElement('tr');
campos.forEach(function (campo) {
var td = document.createElement('td');
td.textContent = campo.value;
td.append('td');
td.appendChild(td);
// td.appendChild('td');
// td.appendChild(td);
});
var tdVolume = document.createElement('td');
tdVolume.textContent = campos[1].value * campos[2].value;
tr.appendChild(tdVolume);
tbody.appendChild(tr);
campos[0].value = '';
campos[1].value = 1;
campos[2].value = 0;
campos[0].focus();
});