<html lang="en">
<head>
<meta charset="utf-8">
<title>Javascript Replacing Existing Elements in DOM</title>
</head>
<body>
<div id="main">
<h1 id="title">My Heading</h1>
<p id="hint"><span>This is some text.</span></p>
</div>
<script>
var hint = document.getElementById("hint");
alert(hint.parentNode.nodeName); // Outputs: DIV
hint.parentNode.style.backgroundColor = "yellow";
</script>
</body>
</html>