I cut records for AM radio, and I was always conscious that AM used to have a great big old bottom on it. So I took most of the bass out of the records and put on more high-end — that made 'em sound cleaner than the others.
Selectors
Methods
#ID { }
document.getElementById("ID")
#footer { }
document.getElementById("footer")
tagName { }
document.getElementsByTagName("tagName")
p { }
document.getElementsByTagName("p")
#nav a { }
document.getElementById("nav").getElementsByTagName("a")
* { }
document.getElementsByTagName("*")
.className { }
document.getElementsByClassName("className")
document.getElementsByClassName = function(name) {
var results = new Array();
var elems = document.getElementsByTagName("*");
for (var i=0; i<elems.length; i++) {
if (elems[i].className.indexOf(name) != -1) {
results[results.length] = elems[i];
}
}
return results;
};
Let's go...
tr:nth-child(2n+1) /* represents every odd row of an HTML table */
tr:nth-child(odd) /* same */
tr:nth-child(2n) /* represents every even row of an HTML table */
tr:nth-child(even) /* same */
tr:nth-child(odd) {
background-color: #9cf;
}
function stripeTables() {
var tables = document.getElementsByTagName("table");
for (var i=0; i<tables.length; i++) {
var rows = tables[i].getElementsByTagName("tr");
for (var j=0; j<rows.length; j=j+2) {
rows[j].backgroundColor = "#9cf";
}
}
}
function addClass(element,name) {
if (!element.className) {
element.className = name;
} else {
element.className+= " ";
element.className+= name;
}
}
function stripeTables() {
var tables = document.getElementsByTagName("table");
for (var i=0; i<tables.length; i++) {
var rows = tables[i].getElementsByTagName("tr");
for (var j=0; j<rows.length; j=j+2) {
addClass(rows[j],"odd");
}
}
}
tbody tr.odd th {
background-color: #69c;
}
tbody tr.odd td {
background-color: #9cf;
}
function stripeLists() {
var lists = document.getElementsByTagName("ol");
for (var i=0; i<lists.length; i++) {
if (lists[i].className.match("striped")) {
var items = lists[i].getElementsByTagName("li");
for (var j=0; j<items.length; j=j+2) {
addClass(items[j],"odd");
}
}
}
}
.rounded {
background-image: url("images/northwest.gif"),
url("images/northeast.gif"),
url("images/southeast.gif"),
url("images/southwest.gif");
background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
background-position: top left, top right, bottom right, bottom left;
}
div
s in the markup?div
s?
function insertCorners(element) {
var corners = new Array("northwest","northeast","southeast","southwest");
for (var i=0; i<corners.length; i++) {
var div = document.createElement("div");
div.className = corners[i];
element.appendChild(div);
}
}
function roundCorners() {
var elements = document.getElementsByClassName("rounded");
for (var i=0; i<elements.length; i++) {
insertCorners(elements[i]);
}
}
blockquote:after {
content: "source: "attr(cite);
}
function blockquotes() {
var quotes = document.getElementsByTagName("blockquote");
for (var i=0; i<quotes.length; i++) {
var source = quotes[i].getAttribute("cite");
if (source) {
var text = document.createTextNode("source: "+source);
quotes[i].appendChild(text);
}
}
}
body {
max-width: 1600px;
}
width:1600px
style on the body
body {
min-width: 800px;
}
width:800px
style on the body
It's the BOM, not the DOM.
setTimeout
setInterval
top
, left
, etc.)background-color
)