Report abuse


document.documentElement.lastChild => Body
document.getElementsByTagName("h1")[0]

document.getElementById("tiger").firstChild


parentNode
childNodes
firstChild
lastChild


getElementsByTagName	// gets element by tag name, such as "div" for <div> "p" for <p> and "h1" for <h1>
getElementById      	// gets element by id such as "something" for <div id = "something">
getAttributeNode		// gets the attributes of element getAttributeNode("id") returns id attribute



<html>
	<head>
		<title>Who Am I exercise</title>
	</head>
	<body>
		<h1> I am a cow </h1>
		<div id = "ranch">
			I am <em> horse</em>, but I wish I was a <span id = "tiger">tiger</span>.
		</div>
		<form>
			<input type= "button" value = "What Am I?" onClick="guess();" />
		</form>
	</body>
</html>


var element = document.documentElement.lastChild;
	element.nodeName => "BODY"
	element.nodeValue => "null"
	
document.getElementById("tiger").lastChild; // spans elements last child is text "tiger"