This is a draft cheat sheet. It is a work in progress and is not finished yet.
FINDING AN ELEMENT
.getElementById(id) |
find an element by element id |
.getElementByTagName(name) |
find elements by tag name |
.getElementByClass(class) |
find element by class |
|
|
CHANGING ELEMENTS
.innerHTML = new content |
change inner HTML of an element |
.attribute = new value |
change the attribute value of element |
.setAttribute(attribute, value) |
change or create the attribute for element |
.style.property = new style |
change the style of an element |
|
|
ADDING AND DELETING ELEMENTS
.createElement(element) |
create element |
.removeChild(element) |
remove element |
.appendChild(element) |
add element at end |
.replaceChild(element) |
replace element |
.write(text) |
write into HTML output stream |
|