Show Menu
Cheatography

Basic HTML DOM methods Cheat Sheet (DRAFT) by [deleted]

This is a draft cheat sheet. It is a work in progress and is not finished yet.

FINDING AN ELEMENT

.getEl­eme­ntB­yId(id)
find an element by element id
.getEl­eme­ntB­yTa­gNa­me(­name)
find elements by tag name
.getEl­eme­ntB­yCl­ass­(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
.setAt­tri­but­e(a­ttr­ibute, value)
change or create the attribute for element
.style.pr­operty = new style
change the style of an element
 

ADDING AND DELETING ELEMENTS

.creat­eEl­eme­nt(­ele­ment)
create element
.remov­eCh­ild­(el­ement)
remove element
.appen­dCh­ild­(el­ement)
add element at end
.repla­ceC­hil­d(e­lement)
replace element
.write­(text)
write into HTML output stream