Black & White Series
DOM
Document Object Model
Web Layers
DOM Tree
JavaScript DOM View
Defining a span
Target
Importing an External JS
Retrieving the span
Object
Inserting HTML content
CSS Selectors
selector | syntax | examples |
---|---|---|
type | tag name | p , h1 |
classe | .classname |
.story |
identifier | #idname |
#show-wd |
Reference: mdn CSS selectors
document.querySelector
querySelector(<selector>)
- Returns the first element within the document that matches the selector
- This element is a DOM object
document.querySelector("#show-wd")
Returns the element identified by show-wd
.
Reference: mdn Document.querySelector()
Element.innerHTML
- JavaScript property
- Gets or Sets the HTML inside an element
div
Example
More Complex innerHTML
André Santanchè
www.ic.unicamp.br/~santanch/
Web2Learn
santanche.github.io/web2learn/