The DOM

The BOM

window vs. document

window === document
// => false
window.location === document.location
// => true

The window

window.x = 7;
x === 7; // true
y = 9;
window.y === 9 // works in reverse too
parseInt('123')         // same
window.parseInt('123')  // thing

Locating HTML Elements

Adding HTML

document.write("<p id='message'>hi</p>");  // :-( this freaks out Firebug Console

var message = document.getElementById('message');
message.innerHTML = "<b>bye</b>!";

let target = document.getElementById('someElement')

let paragraph = document.createElement('p')
paragraph.textContent = "I’ve seen things you people wouldn’t believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain."

target.appendChild(paragraph)

Altering HTML Elements

the style property

Events

Event Name Gotcha

return false

Many event types

References

Next 

Outline

[menu]

/