arr1 = document.getElementsByClassName('btn-add');
arr2 = document.getElementsByClassName('btn-del');
for (var i = 0; i < arr1.length; i++) {
arr1[i].addEventListener('click', func1);
arr2[i].addEventListener('click', func1);
}
function func1() {
bank_id = this.parentNode.parentNode.getElementsByClassName('select-bank')[0].value;
id = this.dataset.id;
del = this.dataset.del;
el_button = this;
console.log(id, bank_id, del);
$.ajax({
method: 'POST',
url: 'cpl_offices_bank_id_by_name_ajax.php',
data: {id: id, bank_id: bank_id, del: del}
}).done(function () {
el_tr = el_button.parentNode.parentNode;
td = document.createElement('td').setAttribute('colspan', '6').setAttribute('style', 'text-align:center;');
if (typeof del !== 'undefined'){
td.innerHTML = "Удалено";
el_tr.innerHTML = '';
el_tr.appendChild(td);
}
else {
td.innerHTML = "Добавлено";
el_tr.innerHTML = '';
el_tr.appendChild(td);
}
setTimeout(function() {td.parentNode.outerHTML = ''}, '10000');
});
}
В результате возникает ошибка:
Cannot read property 'setAttribute' of undefined