JavaScript DOM access
getting that HTML
The document
object
document
objectIn JavaScript we can access the document (global) object simply with the reserved keyword
document
The getElement...
properties
getElement...
propertiesThen, we can access DOM elements, such as all
<h1>
tags like this:
Note that would grab the object representation and not the content of the <h1>
tags!
getElementById(...)
returns the tag object with an
id
attribute of...
getElementsByClassName(...)
returns a list of any element(s) with a
class
attribute of...
getElementsByTagName(...)
returns a list of any element(s) with that tag of
...
e.g.
getElementsByTagName('h1')
for<h1>
tags
Last updated