Answers for "remove child onclick javascript"

1

javascript remove item onclick

function remove(elem){
  elem.parentNode.removeChild(elem);
}
<div id="i", onclick="remove(this)">click</div>
Posted by: Guest on October-02-2020
0

remove child onclick javascript

function itemDone(e) {
    var target, elParent, elGrandParent;

    //Remove Item From the list
    target = e.target;
    // alert(e.target.value);
    elParent = target.parentNode;
    elGrandParent = elParent.parentNode;

    alert(target.parentNode.innerHTML + " Removed From Cart")
    elGrandParent.removeChild(elParent);

    //prevent the link from taking you elsewhere
    e.preventDefault();
}

// Set up event listeners to call itemDone() on click
document.getElementById("shoppinglist").addEventListener('click', function(e) {
    itemDone(e);
}, false);
Posted by: Guest on May-29-2021

Code answers related to "remove child onclick javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language