我正在做作业,但我不知道如何使表格行可以通过单击进行编辑。例如,单击“约翰”我可以修改名称。下面的代码只是一小部分代码,只是为了了解表是如何创建的。任何提示或解决方案表示赞赏。
// Creating Table and Display DATA
let tableBody = document.getElementsByTagName('tbody')[0];
let tr = document.createElement('tr');
let ShowID = document.createElement('td');
let ShowName = document.createElement('td');
let ShowSurname = document.createElement('td');
let ShowAge = document.createElement('td');
let ShowPosition = document.createElement('td');
let ShowYofExperience = document.createElement('td');
let ShowEducation = document.createElement('td');
let ShowStatus = document.createElement('td');
let ShowNote = document.createElement('td');
for(let i = 0; i < candidates.length; i++){
let currentCandidate = candidates[i];
ShowID.innerText = currentCandidate.id;
ShowName.innerText = currentCandidate.name;
ShowSurname.innerText = currentCandidate.surname;
ShowAge.innerText = currentCandidate.age;
ShowPosition.innerText = currentCandidate.position;
ShowYofExperience.innerText = currentCandidate.experience;
ShowEducation.innerText = currentCandidate.education;
ShowStatus.innerText = currentCandidate.status;
ShowNote.innerText = currentCandidate.note;
}
// Checkbox
let ShowCheck = document.createElement('input');
ShowCheck.type = 'checkbox'
ShowCheck.id = 'checked';
ShowCheck.value = 'true';
tr.appendChild(ShowCheck);
tr.appendChild(ShowID);
tr.appendChild(btnPreview);
tr.appendChild(ShowName);
tr.appendChild(ShowSurname);
tr.appendChild(ShowAge);
tr.appendChild(ShowPosition);
tr.appendChild(ShowYofExperience);
tr.appendChild(ShowEducation);
tr.appendChild(ShowStatus);
tr.appendChild(ShowNote);
千巷猫影
相关分类