Common DOM manipulations include:
-
Get elements: You can use
document.getElementById
,document.getElementsByTagName
,document.getElementsByClassName
and other methods to get elements in the page. -
Modify elements: You can use
element.innerHTML
,element.innerText
,element.setAttribute
and other methods to modify the content and attributes of elements. -
document.createElement
Adding elements: New elements can be created with andelement.appendChild
added to the document with . -
Deleting elements:
element.removeChild
Elements can be deleted using the method. -
Modifying styles: You can use
element.style
the attribute to modify the CSS style of an element. -
Event processing: You can use
element.addEventListener
to bind event processing functions to respond to user interaction.