这是我的代码,我正在使用pouchdb在表中显示记录,然后我想通过单击fontawesome垃圾箱图标删除特定记录。我目前已经设置了"doc.rows[0].doc"
,但是无论您单击哪里,它都只会删除第一条记录。
// Show Record
function showRecord() {
db.allDocs({
include_docs: true,
descending: false
}, function(err,
doc) {
for (let i = 0; i < doc.rows.length; i++) {
let obj = doc.rows[i].doc;
let record = "<tr class='cursor'><td>" + obj._id + "</td><td>" +
obj.Name + "</td><td>" + obj.FName + "</td><td>" + obj.Program + "</td> <
td > " +
obj.Start + "</td><td>" + obj.End + "</td><td>" + obj.Admission +
" <
/td> <
td > " + obj.Price +" < /td><td><i class='fas fa-trash cursor' / > < /td> <
/tr>";
tbody.innerHTML += record;
}
});
}
tbody.addEventListener("click", Del);
function Del(e) {
db.allDocs({
include_docs: true,
descending: false
}, function(err,
doc) {
db.remove(doc.rows[0].doc).then(function() {
console.log("Success")
}).catch(function() {
console.log("Error")
});
})
};