Answers for "how to delete an item from an array from adeleting a value in a table javascript"

2

how to delete an item from an array from adeleting a value in a table javascript

//Declare Array
data = [];

//Add the clickListnersEvent to the function that should Delete the item
function clickListners (){
    //Get IDs
    var IDs = allCustomers.map(function(record){
        return record.id;
    });


// for each ID find respective DOM element and attatch event listner

IDs.forEach(function(id){
    //find element
    var tr = document.getElementById(id);
    // attach event listner
    tr.onclick = function(event){
        //get id of clicked tr (tabel row)
        var trID = tr.getAttribute('id');

        data = data.filter(function(record){
            return record.id !== trID;
        });
    var targetTR = document.getElementById(trID);
    targetTR.remove();  
    }  
})
}
Posted by: Guest on May-03-2021

Code answers related to "how to delete an item from an array from adeleting a value in a table javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language