function deleteItem(event) {
// retrieve the name of the task we want to delete
let dataTask = event.target.getAttribute("data-task");
// open a database transaction and delete the task, finding it by the name we retrieved above
let transaction = db.transaction(["toDoList"], "readwrite");
let request = transaction.objectStore("toDoList").delete(dataTask);
// report that the data item has been deleted
transaction.oncomplete = () => {
// delete the parent of the button, which is the list item, so it no longer is displayed
event.target.parentNode.parentNode.removeChild(event.target.parentNode);
note.appendChild(document.createElement("li")).textContent =
`Task "${dataTask}" deleted.`;
};
}IDBObjectStore: delete() method / notebook
IDBObjectStore: delete() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.