Javascript Remove Element By Id Code Example
snippet in javascript

Javascript Remove Element By Id Code Example

user3303

//removing element by ID
var element = document.getElementById("myElementID");
    element.parentNode.removeChild(element);

Javascript Remove Element By Id Code Example

user6434

var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get  "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]