javascriptのtableタグにチェックボックスが付いています
フレームワークを使わず、動的にtbodyを追加しtbodyの中に入っているチェックボックスがあります
このチェックボックスにチェックが入っている蘭を、選択削除ボタンをクリックして削除できるようにしたいです
htmlで以下のコードがあったとします
<table> <thead id="tHeader"> <tr> <th class="thBox"></th> </tr> </thead> <tbody id="tableBody"> </tbody> </table> <script src="app.js"></script>//js
//少しコードを省略
start.addEventListener('click', () => {
const tRecord = document.createElement('tr')
tBody.appendChild(tRecord)
const tId = document.createElement('td')
tRecord.appendChild(thBox)
const tCheck = document.createElement('td')
const tInput = document.createElement('input')
tInput.type = 'checkbox'
tCheck.appendChild(tInput)
tRecord.appendChild(tCheck).classList.add('center')
//これがわからない
const selectionDeleteButton = () => {
const deleteButton = document.createElement('button');
deleteButton.textContent = '選択削除';
deleteButton.addEventListener('click', () => {
todos.splice(tRecord, 1);
showTodos();
});
return deleteButton;
};
選択削除の仕方わかる方いらしたら、ご教授願います
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。