Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

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"