I have a little problem with my code. I cant delete checked checkbox from localstorage, becasue when I checked inputs I cant get id from checked checkbox and compare both arrays.
var products = [];
if (localStorage.getItem("products")) { // jezeli cos sie znajduje w products
products = JSON.parse(localStorage.getItem("products")); // pobiera dane i przekazuje do funkcji
drawTable(products); // rysuje
}
function remove() {
var checked = document.querySelectorAll("input[type='checkbox']:checked"); // :checked - stan ze zaznaczone
checked.forEach(function(checkbox, index, array) { // foreach po tablicy checked
//console.log(document.querySelectorAll("input[type='checkbox']"));
checkbox.parentNode.parentNode.remove(); // usuwanie poszczegolnych tr chb - > chbTd - > tr
});
}
Aucun commentaire:
Enregistrer un commentaire