So I am in the process of learning how to manipulate the DOM with JS and I encountered the terminologies mentioned in the subject. I understand usually with examples so I wrote some code to see the difference but they still rendered the same stuff. I want to know whether if my node is live or not is going to affect my code.
//var parent = document.getElementById('parent');
//var parent = document.querySelector('ul#parent');
//var child_nodes = parent.childNodes;
//parent.appendChild(document.createElement('li'));
<!DOCTYPE html>
<html>
<head>
<title>Live vs Non-live</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="page">
<h1 id="header">List King</h1>
<h2>Buy groceries</h2>
<ul id ="parent">
<li id="one" class="hot"><em>fresh</em> figs</li>
<li id="two" class="hot">pine nuts</li>
<li id="three" class="hot">honey</li>
<li id="four">balsamic vinegar</li>
</ul>
</div>
<script src="js/livenonlive.js"></script>
</body>
</html>
Whether I select the parent ID with getElementById or by querySelector, they still update the document and append the child li.