JS replaceChild & removeChild


html file

<!DOCTYPE html>
<html>
<head>
    <title>DOM Navigation</title>
</head>
<body>
    <ul id= "list">
        <li>orange</li>
        <li>Apple</li>
        <li>Grapes</li> 
        <li>Banana</li>
    </ul>
    <script src="js/dom-create.js"></script>
</body>
</html>


dom-create.js

/*JavaScript ReplaceChild*/

/*var newElement = document.createElement("li");

var newText = document.createTextNode("WOW new Text");

newElement.appendChild(newText);

var target = document.getElementById("list");

var oldElement = target.children[0];*/

//console.log(oldElement);

//target.replaceChild(newElement,oldElement);




/*JavaScript RemoveChild*/

var target = document.getElementById("list");

var oldElement = target.children[1];