<!DOCTYPE html>
<html>
<head>
<title>A Simple Example</title>
</head>
<body>
<div>Some text</div>
</body>
<div class="test">
<span>hi</span>
</div>
DIV > SPAN {
text-decoration: line-through;
}
.test > SPAN {
text-decoration: underline;
}
- count the number of ID selectors in the selector (= a)
- count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
- count the number of type selectors and pseudo-elements in the selector (= c)
document.createElement("div");
document.createElement("a");
document.createElement("table");
...
document.getElementById("element_id")
element.getElementsByClassName("element_class")
element.getElementsByTagName("element_tag")e
element.children
node.parentNode
node.firstChild
node.lastChild
node.parentElement
node.nextSibling
node.previousSibling
document.querySelector("selector_string");
document.querySelectorAll("selector_string");
element.querySelectorAll("selector_string);
<div id="foo">
<span class="moreinfo">
<span>For a unique uploading experience...</span>
<a href="http://fineuploader.com">check it out</a>
</span>
</div>
var foo = document.getElementById("foo");
var more_info = foo.getElementsByClassName("moreinfo")[0];
var link_related_content = more_info.children;
var element = document.getElementById("container");
console.log(element.tagName);
element.tagName === "VIDEO"
element instanceof HTMLVideoElement